:root {
  --bg: #0f0f11;
  --bg-elevated: #16161a;
  --surface: #1c1c21;
  --surface-card: #222228;
  --border: #2e2e38;
  --border-soft: #3a3a44;
  --text: #f2f3f5;
  --text-body: #d4d4dc;
  --text-dim: #a0a4b0;
  --muted: #787c8a;
  --accent: #0078d4;
  --accent-hover: #1a8fe3;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --accent-line: color-mix(in srgb, var(--accent) 42%, transparent);
  --accent-glow: color-mix(in srgb, var(--accent) 30%, transparent);
  --shell-max: 1200px;
  --header-h: 56px;
  --nav-width: min(280px, 100%);
  --radius: 12px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 24px); }
body {
  margin: 0; padding-top: var(--header-h);
  font-family: var(--font); color: var(--text); background: var(--bg);
  line-height: 1.6; font-size: 15px;
}

/* ── Header ── */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-h);
  background: rgba(18,18,22,0.94); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); box-shadow: 0 1px 8px rgba(0,0,0,0.4);
}
.site-header-inner {
  max-width: var(--shell-max); margin: 0 auto; padding: 0 20px;
  height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.site-logo {
  display: flex; align-items: center; gap: 8px; color: #fff;
  font-weight: 700; font-size: 1.05rem; text-decoration: none; white-space: nowrap;
}
.site-logo svg { width: 24px; height: 24px; flex-shrink: 0; }
.site-nav { display: flex; gap: 4px; align-items: center; }
.site-nav a {
  color: var(--text-dim); text-decoration: none; font-size: 0.85rem;
  padding: 6px 12px; border-radius: 6px; transition: color 0.15s, background 0.15s;
}
.site-nav a:hover, .site-nav a.active { color: #fff; background: rgba(255,255,255,0.06); }
.site-nav-actions { display: flex; align-items: center; gap: 10px; }
.btn-store {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: #fff; border: none; border-radius: 6px;
  padding: 7px 14px; font-size: 0.82rem; font-weight: 600; cursor: pointer;
  text-decoration: none; transition: background 0.15s;
}
.btn-store:hover { background: var(--accent-hover); }
.btn-store img { height: 18px; }
.lang-switch { display: flex; gap: 2px; padding: 3px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border-soft); }
.lang-select {
  appearance: none; -webkit-appearance: none;
  background-color: var(--surface-card); color: var(--text-body);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 26px 6px 10px; font-size: 0.85rem; font-family: var(--font); cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' fill='none' stroke='%23a0a4b0' stroke-width='1.6'/></svg>");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 11px;
}
.lang-select:hover { border-color: var(--accent); color: #fff; }
.lang-select option { background: var(--surface-card); color: var(--text-body); }

/* ── Language toggle ── */
.t-en { display: none; }
body.lang-en .t-zh { display: none; }
body.lang-en .t-en { display: inline; }
body.lang-en .t-en.block, body.lang-en article .t-en { display: block; }
body.lang-en .t-zh.block, article .t-zh.block { display: block; }
body.lang-en article .t-zh { display: none; }
body.lang-en article .t-en { display: block; }

/* ── Layout ── */
.page-shell { max-width: var(--shell-max); margin: 0 auto; padding: 24px 20px 64px; min-height: calc(100vh - var(--header-h)); }
.layout { display: flex; align-items: flex-start; gap: 24px; }
.sidebar {
  width: var(--nav-width); flex-shrink: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  position: sticky; top: calc(var(--header-h) + 12px); align-self: flex-start;
  max-height: calc(100vh - var(--header-h) - 28px); overflow-y: auto;
  padding: 0.8rem 0 1.2rem; box-shadow: 0 2px 16px rgba(0,0,0,0.3); z-index: 2;
}
.sidebar-brand { padding: 0 1rem 0.8rem; border-bottom: 1px solid var(--border); margin-bottom: 0.4rem; }
.sidebar-brand h2 { margin: 0; font-size: 1rem; font-weight: 700; color: #fff; }
.sidebar-brand .store-link { margin-top: 0.6rem; display: block; }
.sidebar-brand .store-link img { width: 100%; border-radius: 8px; display: block; }
.brand-sub { color: var(--text-dim); font-size: 0.85rem; margin: 4px 0 10px; }
.nav-label {
  font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--muted); padding: 0.6rem 1rem 0.3rem;
}
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-list li a {
  display: block; padding: 0.5rem 0.9rem; margin: 2px 8px; border-radius: 8px;
  color: var(--text-body); text-decoration: none; font-size: 0.82rem;
  border-left: 3px solid transparent; transition: all 0.15s;
}
.nav-list li a:hover { background: var(--accent-soft); color: #fff; }
.nav-list li a.active {
  background: var(--accent); color: #fff; font-weight: 600;
  border-left-color: #fff; box-shadow: 0 0 0 1px var(--accent-glow);
}

/* ── Content ── */
.main-content { flex: 1; min-width: 0; }
.article-header { margin-bottom: 1.5rem; }
.article-header h1 { font-size: 1.8rem; font-weight: 700; margin: 0 0 0.4rem; color: #fff; line-height: 1.3; }
.article-header p { color: var(--text-dim); font-size: 0.95rem; margin: 0; }

article section { margin-bottom: 2rem; }
article h2 {
  font-size: 1.25rem; font-weight: 700; color: #fff; margin: 2rem 0 0.8rem;
  padding-bottom: 0.5rem; border-bottom: 1px solid var(--border);
}
article h3 { font-size: 1.05rem; font-weight: 600; color: var(--text); margin: 1.4rem 0 0.6rem; }
article p { color: var(--text-body); margin: 0.6rem 0; }
article ul, article ol { color: var(--text-body); padding-left: 1.5rem; margin: 0.5rem 0; }
article li { margin: 0.3rem 0; }
article strong { color: #fff; }
article a { color: var(--accent-hover); }
article code {
  background: var(--surface-card); border: 1px solid var(--border-soft); border-radius: 4px;
  padding: 1px 5px; font-size: 0.86em; font-family: "Cascadia Code", Consolas, monospace; color: var(--text);
}
article .tip {
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  border-radius: 8px; padding: 0.8rem 1rem; margin: 1rem 0; font-size: 0.9rem;
  color: var(--text-dim);
}
article .tip strong { color: var(--accent-hover); }
article .warn {
  background: rgba(245,180,74,0.09); border: 1px solid rgba(245,180,74,0.35);
  border-radius: 8px; padding: 0.8rem 1rem; margin: 1rem 0; font-size: 0.9rem;
  color: var(--text-dim);
}
article .warn strong { color: #f5b44a; }
article figure, article .screenshot { margin: 1.2rem 0; text-align: center; }
article .screenshot img, article figure img {
  max-width: 100%; height: auto; border-radius: var(--radius);
  border: 1px solid var(--border); display: block; margin: 0 auto;
  cursor: pointer; transition: opacity 0.15s;
}
article .screenshot img:hover, article figure img:hover { opacity: 0.85; }
article .screenshot .caption, article figcaption {
  font-size: 0.8rem; color: var(--muted); margin-top: 0.5rem;
}
article table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 0.9rem; }
article th, article td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; color: var(--text-body); }
article th { background: var(--surface-card); color: #fff; font-weight: 600; }
article kbd {
  display: inline-block; padding: 2px 6px; font-size: 0.8rem; font-family: inherit;
  background: var(--surface-card); border: 1px solid var(--border-soft);
  border-radius: 4px; color: var(--text-dim); margin: 0 2px;
}

/* Lightbox */
.lightbox {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9999; background: rgba(0,0,0,0.92);
  align-items: center; justify-content: center; cursor: pointer;
}
.lightbox.show { display: flex; }
.lightbox img { max-width: 93vw; max-height: 93vh; border-radius: 8px; box-shadow: 0 8px 48px rgba(0,0,0,0.6); }
.lightbox-close {
  position: absolute; top: 16px; right: 24px;
  color: rgba(255,255,255,0.7); font-size: 32px; cursor: pointer;
  background: none; border: none; line-height: 1;
}
.lightbox-close:hover { color: #fff; }

/* ── Pager ── */
.article-pager {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin: 36px 0 10px; padding-top: 20px; border-top: 1px solid var(--border);
}
.article-pager a, .article-pager .disabled {
  padding: 7px 13px; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-body); text-decoration: none; font-size: 0.9rem; white-space: nowrap;
}
.article-pager a:hover { border-color: var(--accent); color: #fff; }
.article-pager a.current { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.article-pager .disabled { opacity: 0.35; }
.article-pager .spacer { flex: 1; }

/* ── Footer ── */
.site-footer {
  max-width: var(--shell-max); margin: 0 auto; padding: 1.5rem 20px;
  border-top: 1px solid var(--border); text-align: center;
  color: var(--muted); font-size: 0.78rem;
}
.site-footer a { color: var(--text-dim); text-decoration: none; }
.site-footer a:hover { color: var(--accent-hover); }

/* ── Left fixed ad ── */
.ad-left {
  position: fixed; left: max(8px, calc((100vw - var(--shell-max)) / 2 - 172px));
  top: calc(var(--header-h) + 12px); z-index: 50;
  width: 160px; min-height: 600px;
}
@media (max-width: 1480px) { .ad-left { display: none; } }

/* ── Mobile ── */
@media (max-width: 860px) {
  .sidebar { display: none; }
  .site-nav a { font-size: 0.75rem; padding: 4px 8px; }
  .article-header h1 { font-size: 1.4rem; }
  .article-pager { gap: 6px; }
  .article-pager a, .article-pager .disabled { padding: 6px 10px; font-size: 0.82rem; }
}
