: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: #2563eb;
      --accent-hover: #3b82f6;
      --accent-glow: rgba(37,99,235,0.3);
      --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-btn {
      border: none; cursor: pointer; font-family: inherit; font-size: 0.78rem; font-weight: 500;
      padding: 5px 10px; border-radius: 6px; background: transparent; color: var(--text-dim);
      transition: background 0.15s, color 0.15s;
    }
    .lang-btn:hover { color: var(--text); }
    .lang-btn.active { background: var(--accent); color: #fff; }

    /* ── 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; }
    .sidebar-brand .store-link img { width: 100%; border-radius: 8px; display: block; }
    .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: rgba(37,99,235,0.1); 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);
    }
    .nav-sub { list-style: none; margin: 0; padding: 0 0 0 0.6rem; }
    .nav-sub li a {
      display: block; padding: 0.35rem 0.8rem 0.35rem 1.4rem; margin: 1px 8px;
      border-radius: 6px; color: var(--text-dim); text-decoration: none; font-size: 0.78rem;
      border-left: 2px solid transparent; transition: all 0.15s;
    }
    .nav-sub li a:hover { background: rgba(37,99,235,0.08); color: var(--text); }
    .nav-sub li a.active { background: rgba(37,99,235,0.18); color: var(--text); font-weight: 600; border-left-color: var(--accent); }

    /* ── 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; }
    .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 .tip {
      background: rgba(37,99,235,0.08); border: 1px solid rgba(37,99,235,0.2);
      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 .screenshot {
      margin: 1.2rem 0; text-align: center;
    }
    article .screenshot img {
      max-width: 100%; border-radius: var(--radius);
      border: 1px solid var(--border); display: block;
      cursor: pointer; transition: opacity 0.15s;
    }
    article .screenshot img:hover { opacity: 0.85; }
    article .screenshot .caption {
      font-size: 0.8rem; color: var(--muted); margin-top: 0.4rem;
    }
    /* 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; }
    /* language-specific screenshot */
    .screenshot .ss-cn { display: block; }
    .screenshot .ss-en { display: none; }
    body.lang-en .screenshot .ss-cn { display: none; }
    body.lang-en .screenshot .ss-en { display: block; }
    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;
    }

    /* ── Related Apps ── */
    /* ── Right sidebar: Related Apps ── */
    .sidebar-right {
      width: 220px; 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: 1rem; box-shadow: 0 2px 16px rgba(0,0,0,0.3); z-index: 1;
    }
    .sidebar-right h2 { font-size: 0.85rem; font-weight: 700; color: #fff; margin: 0 0 0.8rem; }
    .related-list { display: flex; flex-direction: column; gap: 10px; }
    .related-card {
      display: flex; align-items: flex-start; gap: 8px;
      background: var(--surface-card); border: 1px solid var(--border); border-radius: 8px;
      padding: 8px; text-decoration: none; transition: border-color 0.15s;
    }
    .related-card:hover { border-color: var(--accent); }
    .related-card img { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
    .related-card h4 { color: var(--text-body); font-size: 0.72rem; margin: 0; font-weight: 500; line-height: 1.35; }

    /* ── 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; }
      .sidebar-right { display: none; }
      .site-nav a { font-size: 0.75rem; padding: 4px 8px; }
    }

/* ── tutorial pages (carried over from the original 16-page tutorial) ─────── */
.brand-sub { color: var(--text-dim); font-size: 0.85rem; margin: 4px 0 10px; }
article img { max-width: 100% !important; height: auto !important; }
article .screenshot { display: block; margin: 16px 0; }
article .screenshot img { border: 1px solid var(--border); border-radius: 8px; }
.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 { 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 .spacer { flex: 1; }

/* language dropdown (replaces the two-button toggle) */
.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); }
