:root {
  --tg-blue: #229ED9;
  --tg-blue-2: #2AABEE;
  --tg-blue-dark: #1c8fc4;
  --bg: #f4f7fb;
  --bg-soft: #eef3f9;
  --card: #ffffff;
  --text: #1f2a37;
  --text-soft: #5a6b7b;
  --text-mute: #8494a3;
  --border: #e4ebf3;
  --shadow: 0 1px 3px rgba(20, 40, 70, .06), 0 8px 24px rgba(20, 40, 70, .05);
  --shadow-lg: 0 12px 40px rgba(20, 40, 70, .12);
  --radius: 16px;
  --sidebar-w: 300px;

  --tip-bg: #e8f6ff; --tip-bd: #b9e3f8; --tip-tx: #0b5c85; --tip-ac: #229ED9;
  --info-bg: #eef2f7; --info-bd: #d9e2ec; --info-tx: #47586a; --info-ac: #8494a3;
  --warn-bg: #fff6e5; --warn-bd: #ffe0a8; --warn-tx: #8a5300; --warn-ac: #f0a500;
  --danger-bg: #ffeef0; --danger-bd: #ffd0d6; --danger-tx: #a11f2e; --danger-ac: #e5384b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1621;
    --bg-soft: #131f2c;
    --card: #17212b;
    --text: #e7eef6;
    --text-soft: #a7b7c6;
    --text-mute: #6d8091;
    --border: #24313f;
    --shadow: 0 1px 3px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    --shadow-lg: 0 12px 40px rgba(0,0,0,.4);

    --tip-bg: #10303f; --tip-bd: #1c4a60; --tip-tx: #7fd0f5; --tip-ac: #2AABEE;
    --info-bg: #1a2530; --info-bd: #2a3846; --info-tx: #9fb2c2; --info-ac: #6d8091;
    --warn-bg: #33270f; --warn-bd: #55420f; --warn-tx: #f4c66b; --warn-ac: #f0a500;
    --danger-bg: #331a1e; --danger-bd: #5a2830; --danger-tx: #f79aa5; --danger-ac: #e5384b;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--tg-blue); text-decoration: none; }

/* ---------- Top bar (mobile) ---------- */
.topbar {
  display: none;
  position: sticky; top: 0; z-index: 40;
  align-items: center; gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--tg-blue-2), var(--tg-blue));
  color: #fff;
  box-shadow: 0 2px 12px rgba(34,158,217,.3);
}
.topbar .brand-mini { font-weight: 800; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.topbar .logo-dot {
  width: 28px; height: 28px; border-radius: 8px;
  background: rgba(255,255,255,.2);
  display: grid; place-items: center; font-size: 16px;
}
.menu-btn {
  margin-left: auto;
  background: rgba(255,255,255,.18);
  border: none; color: #fff;
  width: 40px; height: 40px; border-radius: 10px;
  font-size: 18px; cursor: pointer;
  display: grid; place-items: center;
}

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  z-index: 30;
}
.sidebar-head {
  padding: 24px 22px 18px;
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex; align-items: center; gap: 12px;
}
.brand .logo {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, var(--tg-blue-2), var(--tg-blue));
  display: grid; place-items: center;
  font-size: 22px;
  box-shadow: 0 6px 16px rgba(34,158,217,.35);
}
.brand .title { font-size: 17px; font-weight: 800; letter-spacing: .3px; }
.brand .subtitle { font-size: 12px; color: var(--text-mute); margin-top: 2px; }

.nav {
  flex: 1; overflow-y: auto;
  padding: 12px 12px 24px;
}
.nav-section-label {
  font-size: 11px; font-weight: 700; letter-spacing: 1px;
  color: var(--text-mute); text-transform: uppercase;
  padding: 14px 12px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px;
  border-radius: 11px;
  cursor: pointer;
  color: var(--text-soft);
  transition: background .15s, color .15s;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg-soft); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, var(--tg-blue-2), var(--tg-blue));
  color: #fff;
  box-shadow: 0 6px 16px rgba(34,158,217,.3);
}
.nav-item.active .nav-num { background: rgba(255,255,255,.25); color: #fff; }
.nav-item.active .nav-cat { color: rgba(255,255,255,.85); }
.nav-num {
  flex-shrink: 0;
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--bg-soft);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  color: var(--text-mute);
}
.nav-text { flex: 1; min-width: 0; }
.nav-title {
  font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-cat { font-size: 11px; color: var(--text-mute); }

.sidebar-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-mute);
  text-align: center;
}

/* ---------- Main ---------- */
.main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  align-items: center;
}
.content {
  width: 100%;
  max-width: 820px;
  padding: 40px 32px 80px;
}

.article-head { margin-bottom: 28px; }
.crumb {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-mute);
  margin-bottom: 14px;
}
.badge-cat {
  display: inline-block;
  padding: 4px 12px; border-radius: 999px;
  background: var(--tip-bg); color: var(--tip-tx);
  font-size: 12px; font-weight: 700;
}
.badge-page {
  padding: 4px 12px; border-radius: 999px;
  background: var(--bg-soft); color: var(--text-soft);
  font-size: 12px; font-weight: 600;
}
.article-title {
  font-size: 30px; font-weight: 850; line-height: 1.3;
  display: flex; align-items: center; gap: 14px;
}
.article-title .emoji {
  font-size: 34px;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,.12));
}

/* ---------- Section cards ---------- */
.section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 26px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  animation: rise .4s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.section-heading {
  font-size: 18px; font-weight: 800;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--border);
}
.section p { color: var(--text-soft); margin: 8px 0; }
.section .sub {
  font-weight: 700; font-size: 15px;
  margin: 16px 0 8px; color: var(--text);
}
.section .sub:first-child { margin-top: 0; }

/* Lists */
ul.list { list-style: none; margin: 8px 0; display: grid; gap: 8px; }
ul.list li {
  display: flex; gap: 10px; align-items: flex-start;
  color: var(--text-soft);
  padding: 9px 14px;
  background: var(--bg-soft);
  border-radius: 10px;
  font-size: 14.5px;
}
ul.list li .mk { flex-shrink: 0; font-weight: 700; line-height: 1.6; }
ul.list.dot li .mk { color: var(--tg-blue); }
ul.list li.ok .mk { color: #22a06b; }
ul.list li.no .mk { color: var(--danger-ac); }
ul.list.num { counter-reset: li; }
ul.list.num li .mk {
  width: 22px; height: 22px; border-radius: 7px;
  background: linear-gradient(135deg, var(--tg-blue-2), var(--tg-blue));
  color: #fff; display: grid; place-items: center;
  font-size: 12px; margin-top: 1px;
}

/* Notes */
.note {
  display: flex; gap: 12px;
  padding: 14px 16px; border-radius: 12px;
  margin: 12px 0;
  border: 1px solid;
  font-size: 14.5px; line-height: 1.65;
  border-left-width: 4px;
}
.note .note-ico { font-size: 18px; flex-shrink: 0; line-height: 1.4; }
.note.tip { background: var(--tip-bg); border-color: var(--tip-bd); border-left-color: var(--tip-ac); color: var(--tip-tx); }
.note.info { background: var(--info-bg); border-color: var(--info-bd); border-left-color: var(--info-ac); color: var(--info-tx); }
.note.warn { background: var(--warn-bg); border-color: var(--warn-bd); border-left-color: var(--warn-ac); color: var(--warn-tx); }
.note.danger { background: var(--danger-bg); border-color: var(--danger-bd); border-left-color: var(--danger-ac); color: var(--danger-tx); }

/* Buttons */
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.btn {
  flex: 1 1 auto; min-width: 180px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 18px; border-radius: 12px;
  font-weight: 700; font-size: 14.5px;
  border: 1px solid var(--border);
  background: var(--bg-soft); color: var(--text);
  transition: transform .12s, box-shadow .12s, background .12s;
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.btn.primary {
  background: linear-gradient(135deg, var(--tg-blue-2), var(--tg-blue));
  color: #fff; border-color: transparent;
  box-shadow: 0 6px 16px rgba(34,158,217,.3);
}
.btn.primary:hover { box-shadow: 0 10px 24px rgba(34,158,217,.4); }

/* Q&A */
.qa {
  border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden;
  margin: 10px 0; background: var(--bg-soft);
}
.qa summary {
  padding: 13px 16px; cursor: pointer;
  font-weight: 700; font-size: 14.5px;
  display: flex; align-items: center; gap: 10px;
  list-style: none;
}
.qa summary::-webkit-details-marker { display: none; }
.qa summary::before {
  content: "❓"; font-size: 15px;
}
.qa summary::after {
  content: "＋"; margin-left: auto;
  color: var(--tg-blue); font-weight: 800; font-size: 18px;
  transition: transform .2s;
}
.qa[open] summary::after { content: "－"; }
.qa .qa-body {
  padding: 0 16px 14px 42px;
  color: var(--text-soft); font-size: 14px;
}

/* Image */
.img-wrap {
  margin: 12px 0; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}
.img-wrap img { width: 100%; display: block; cursor: zoom-in; }
.img-cap { font-size: 12px; color: var(--text-mute); padding: 8px 12px; text-align: center; }

/* Pager */
.pager {
  display: flex; gap: 12px; margin-top: 28px;
}
.pager a {
  flex: 1; padding: 16px 18px;
  border: 1px solid var(--border); border-radius: 14px;
  background: var(--card); box-shadow: var(--shadow);
  transition: transform .12s, box-shadow .12s;
  min-width: 0;
}
.pager a:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.pager a.next { text-align: right; }
.pager .dir { font-size: 12px; color: var(--text-mute); }
.pager .pg-title {
  font-weight: 700; color: var(--text); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pager a.disabled { opacity: .4; pointer-events: none; }

/* ---------- Mobile drawer ---------- */
.overlay {
  display: none;
  position: fixed; inset: 0; z-index: 25;
  background: rgba(10,20,35,.5);
  backdrop-filter: blur(2px);
}
.overlay.show { display: block; }

/* Lightbox */
.lightbox {
  display: none;
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,.9);
  align-items: center; justify-content: center;
  padding: 24px; cursor: zoom-out;
}
.lightbox.show { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; }

@media (max-width: 900px) {
  .topbar { display: flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform .28s ease;
    box-shadow: var(--shadow-lg);
    width: 84%; max-width: 320px;
  }
  .sidebar.open { transform: none; }
  .content { padding: 24px 18px 70px; }
  .article-title { font-size: 24px; }
  .article-title .emoji { font-size: 27px; }
  .section { padding: 20px 18px; }
  .btn { min-width: 100%; }
}
