/* ========== Reset & Variables ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a14;
  --card-bg: rgba(255,255,255,0.035);
  --card-border: rgba(255,255,255,0.07);
  --card-hover-bg: rgba(255,255,255,0.055);
  --card-hover-border: rgba(255,255,255,0.14);
  --card-shadow: rgba(0,0,0,0.25);
  --text: #e4e4ec;
  --text-secondary: #9494a8;
  --text-tertiary: #6b6b80;
  --link-color: #8fa8ff;
  --link-hover: #b8c8ff;
  --radius: 18px;
  --code-bg: rgba(0,0,0,0.3);
  --code-border: rgba(255,255,255,0.08);
  --step-num-bg: rgba(140,155,220,0.18);
  --step-num-color: #a0b0e0;
  --toc-active-bg: rgba(140,155,220,0.12);
  --btn-link-bg: rgba(140,155,220,0.12);
  --btn-link-border: rgba(140,155,220,0.22);
  --btn-link-hover-bg: rgba(140,155,220,0.2);
  --pros-bg: rgba(140,155,220,0.14);
  --pros-label: #a0b0e0;
  --cons-label: #b89040;
  --strip-bg: linear-gradient(180deg, rgba(38,38,62,0.88) 0%, rgba(22,22,44,0.85) 100%);
  --strip-border: rgba(100,110,185,0.55);
  --strip-divider: rgba(100,110,185,0.4);
  --float-btn-bg: rgba(42,42,75,0.7);
  --float-btn-border: rgba(100,110,185,0.58);
  --float-btn-hover-bg: rgba(58,58,100,0.82);
  --float-btn-hover-border: rgba(120,130,205,0.75);
  --scroll-thumb: rgba(130,155,220,0.35);
  --scroll-thumb-hover: rgba(130,155,220,0.55);
  --float-w-bg: rgba(22,22,44,0.85);
}

[data-theme="light"] {
  --bg: #f3eff3;
  --card-bg: rgba(255,255,255,0.62);
  --card-border: rgba(0,0,0,0.06);
  --card-hover-bg: rgba(255,255,255,0.82);
  --card-hover-border: rgba(251,114,153,0.22);
  --card-shadow: rgba(0,0,0,0.06);
  --text: #18181e;
  --text-secondary: #6b6b80;
  --text-tertiary: #999;
  --link-color: #d44070;
  --link-hover: #fb7299;
  --code-bg: rgba(0,0,0,0.04);
  --code-border: rgba(0,0,0,0.08);
  --step-num-bg: rgba(251,114,153,0.18);
  --step-num-color: #b05060;
  --toc-active-bg: rgba(251,114,153,0.12);
  --btn-link-bg: rgba(251,114,153,0.12);
  --btn-link-border: rgba(251,114,153,0.22);
  --btn-link-hover-bg: rgba(251,114,153,0.2);
  --pros-bg: rgba(251,114,153,0.14);
  --pros-label: #a04058;
  --cons-label: #8a6830;
  --strip-bg: linear-gradient(180deg, rgba(253,215,225,0.88) 0%, rgba(255,255,255,0.99) 100%);
  --strip-border: rgba(251,170,190,0.82);
  --strip-divider: rgba(251,170,190,0.55);
  --float-btn-bg: rgba(253,218,228,0.8);
  --float-btn-border: rgba(251,170,190,0.85);
  --float-btn-hover-bg: rgba(253,205,218,0.92);
  --float-btn-hover-border: rgba(251,140,165,0.95);
  --scroll-thumb: rgba(200,130,160,0.3);
  --scroll-thumb-hover: rgba(200,130,160,0.5);
  --float-w-bg: rgba(255,255,255,0.98);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0%25' stop-color='%23b8c8ff'/%3E%3Cstop offset='100%25' stop-color='%238c96ff'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M16 27 C16 27 4 19 4 11 C4 5 8 3 12 7.5 C14 10 15 12 16 14 C17 12 18 10 20 7.5 C24 3 28 5 28 11 C28 19 16 27 16 27 Z' fill='url(%23g)' stroke='%23fff' stroke-width='2' stroke-linejoin='round' transform='rotate(145 16 16)'/%3E%3C/svg%3E") 19 6, auto;
}
input, textarea, [contenteditable] {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='30' viewBox='0 0 14 30'%3E%3Crect x='4' y='4' width='6' height='22' rx='3' fill='%238c96ff' stroke='%23fff' stroke-width='1.3'/%3E%3Crect x='1' y='1' width='12' height='5' rx='2.5' fill='%238c96ff' stroke='%23fff' stroke-width='1'/%3E%3Crect x='1' y='24' width='12' height='5' rx='2.5' fill='%238c96ff' stroke='%23fff' stroke-width='1'/%3E%3C/svg%3E") 7 15, text;
}
a, button, [role="button"], .float-btn, .bookmark-tab, .toc-item, .step-img {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='32' viewBox='0 0 40 32'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0%25' stop-color='%23b8c8ff'/%3E%3Cstop offset='100%25' stop-color='%238c96ff'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect x='1.5' y='4' width='4' height='9' rx='2' fill='url(%23g)' stroke='%23fff' stroke-width='1'/%3E%3Crect x='7' y='1.5' width='4.5' height='12.5' rx='2.25' fill='url(%23g)' stroke='%23fff' stroke-width='1'/%3E%3Crect x='13' y='0.5' width='5' height='15' rx='2.5' fill='url(%23g)' stroke='%23fff' stroke-width='1'/%3E%3Crect x='19.5' y='2.5' width='5' height='12' rx='2.5' fill='url(%23g)' stroke='%23fff' stroke-width='1'/%3E%3Crect x='1.5' y='13' width='25' height='15' rx='6' fill='url(%23g)' stroke='%23fff' stroke-width='1.5'/%3E%3Crect x='0.5' y='18' width='5.5' height='8' rx='2.75' fill='url(%23g)' stroke='%23fff' stroke-width='1.2'/%3E%3C/svg%3E") 16 1, pointer;
}

/* Light theme cursors */
[data-theme="light"] body {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0%25' stop-color='%23ffb3c6'/%3E%3Cstop offset='100%25' stop-color='%23fb7299'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M16 27 C16 27 4 19 4 11 C4 5 8 3 12 7.5 C14 10 15 12 16 14 C17 12 18 10 20 7.5 C24 3 28 5 28 11 C28 19 16 27 16 27 Z' fill='url(%23g)' stroke='%23fff' stroke-width='2' stroke-linejoin='round' transform='rotate(145 16 16)'/%3E%3C/svg%3E") 19 6, auto;
}
[data-theme="light"] input, [data-theme="light"] textarea, [data-theme="light"] [contenteditable] {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='30' viewBox='0 0 14 30'%3E%3Crect x='4' y='4' width='6' height='22' rx='3' fill='%23fb7299' stroke='%23fff' stroke-width='1.3'/%3E%3Crect x='1' y='1' width='12' height='5' rx='2.5' fill='%23fb7299' stroke='%23fff' stroke-width='1'/%3E%3Crect x='1' y='24' width='12' height='5' rx='2.5' fill='%23fb7299' stroke='%23fff' stroke-width='1'/%3E%3C/svg%3E") 7 15, text;
}
[data-theme="light"] a, [data-theme="light"] button, [data-theme="light"] [role="button"], [data-theme="light"] .float-btn, [data-theme="light"] .bookmark-tab, [data-theme="light"] .toc-item, [data-theme="light"] .step-img {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='32' viewBox='0 0 40 32'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0%25' stop-color='%23ffb3c6'/%3E%3Cstop offset='100%25' stop-color='%23fb7299'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect x='1.5' y='4' width='4' height='9' rx='2' fill='url(%23g)' stroke='%23fff' stroke-width='1'/%3E%3Crect x='7' y='1.5' width='4.5' height='12.5' rx='2.25' fill='url(%23g)' stroke='%23fff' stroke-width='1'/%3E%3Crect x='13' y='0.5' width='5' height='15' rx='2.5' fill='url(%23g)' stroke='%23fff' stroke-width='1'/%3E%3Crect x='19.5' y='2.5' width='5' height='12' rx='2.5' fill='url(%23g)' stroke='%23fff' stroke-width='1'/%3E%3Crect x='1.5' y='13' width='25' height='15' rx='6' fill='url(%23g)' stroke='%23fff' stroke-width='1.5'/%3E%3Crect x='0.5' y='18' width='5.5' height='8' rx='2.75' fill='url(%23g)' stroke='%23fff' stroke-width='1.2'/%3E%3C/svg%3E") 16 1, pointer;
}

/* ---- Background decorations ---- */
.bg-decor { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.blob {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.12;
}
.blob-1 { width: 400px; height: 400px; background: rgba(140,120,220,0.5); top: -80px; left: -80px; }
.blob-2 { width: 350px; height: 350px; background: rgba(200,130,160,0.4); bottom: 100px; right: -100px; }
.blob-3 { width: 300px; height: 300px; background: rgba(120,160,220,0.35); top: 40%; left: 50%; }

/* ---- Floating bookmark strip ---- */
.float-wrapper {
  position: fixed; top: 0; right: 20px; z-index: 50;
  filter: drop-shadow(0 1px 8px rgba(0,0,0,0.18));
  width: 52px;
}

.float-stack {
  overflow: hidden;
  max-height: 32px;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--strip-bg);
  border: 1.5px solid var(--strip-border);
  border-top: none;
  border-bottom: none;
  backdrop-filter: blur(40px); -webkit-backdrop-filter: blur(40px);
}
.float-stack.open { max-height: 360px; }

.float-w {
  width: 52px;
  height: 28px;
  margin-top: -1px;
  background: var(--float-w-bg);
  border: 1.5px solid var(--strip-border);
  border-top: none;
  backdrop-filter: blur(40px); -webkit-backdrop-filter: blur(40px);
  clip-path: polygon(0 0, 25% 100%, 50% 0, 75% 100%, 100% 0);
}

.bookmark-strip {
  width: 52px;
  display: flex; flex-direction: column;
  align-items: center;
  position: relative;
  padding: 0 0 10px 0;
}

.bookmark-tab {
  width: 100%; height: 32px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; user-select: none;
  color: var(--text-tertiary);
  font-size: 0.4rem;
  transition: color 0.3s;
  position: relative;
}
.bookmark-tab:hover { color: var(--text-secondary); }
.bookmark-tab::after {
  content: '展开';
  font-size: 0.72rem;
  color: var(--link-color);
  opacity: 0.65;
}
.float-stack.open .bookmark-tab::after {
  content: '收起';
}

.bookmark-buttons {
  display: flex; flex-direction: column; gap: 7px;
  align-items: center;
  padding: 0 0 4px 0;
}

.float-btn, .theme-toggle {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--float-btn-bg);
  border: 1.5px solid var(--float-btn-border);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  color: var(--text); font-size: 0.95rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.3s; cursor: pointer; text-decoration: none;
  line-height: 1;
}
.float-btn:hover, .theme-toggle:hover {
  background: var(--float-btn-hover-bg);
  border-color: var(--float-btn-hover-border);
  transform: scale(1.08);
}

#backToTop { display: none; }
#backToTop.visible { display: flex; }

/* ---- Layout (universal) ---- */
.app { max-width: 1100px; margin: 0 auto; padding: 40px 24px 60px; position: relative; z-index: 1; }

/* ---- TOC toggle (mobile) ---- */
.toc-toggle { display: none; }
.toc-popup  { display: none; }

/* ---- Shared content ---- */
.back-link { display: inline-block; color: var(--text-secondary); text-decoration: none; font-size: 0.82rem; margin-bottom: 28px; }
.back-link:hover { color: var(--link-hover); }

.page-header { margin-bottom: 20px; }
.page-header h1 { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.01em; }
.page-header p  { font-size: 0.82rem; color: var(--text-secondary); margin-top: 4px; }

.page-footer { text-align: center; margin-top: 32px; padding-top: 18px; border-top: 1px solid var(--card-border); }
.page-footer a { font-size: 0.78rem; color: var(--link-color); text-decoration: none; }
.page-footer a:hover { color: var(--link-hover); }

/* ---- Image Lightbox ---- */
.lightbox {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.85); backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  align-items: center; justify-content: center;
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 92vw; max-height: 92vh; object-fit: contain;
  border-radius: 12px;
  animation: lbZoom 0.2s ease-out;
}
@keyframes lbZoom { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---- Mobile TOC popup ---- */
@media (max-width: 768px) {
  .toc-toggle { display: flex; }
  .toc-popup {
    position: fixed; top: 68px; right: 84px; z-index: 51;
    background: var(--bg); border: 1px solid var(--card-border);
    backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
    border-radius: 14px; padding: 12px; min-width: 200px;
    max-height: calc(100vh - 96px); overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.35);
    opacity: 0; transform: translateY(-6px); pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
  }
  .toc-popup.open { opacity: 1; transform: translateY(0); pointer-events: auto; display: block; }
  .toc-popup .toc-item { font-size: 0.82rem; padding: 8px 12px; }
  .toc-popup .toc-part { font-size: 0.68rem; }
  .toc-popup::-webkit-scrollbar { width: 4px; }
  .toc-popup::-webkit-scrollbar-track { background: transparent; }
  .toc-popup::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 4px; }
  .toc-popup::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); }
  .toc-popup { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
}

@media (max-width: 560px) {
  .app { padding: 24px 14px 40px; }
  .page-header h1 { font-size: 1.1rem; }
}

/* ---- Firework particles ---- */
.firework-particle {
  position: fixed; z-index: 200; pointer-events: none;
  width: 4px; height: 4px; border-radius: 50%;
  animation: fwBurst 0.9s ease-out forwards;
}
.firework-particle.star {
  width: 2px; height: 6px; border-radius: 0;
  animation: fwBurst 0.9s ease-out forwards, fwStar 0.9s ease-out forwards;
}
@keyframes fwBurst {
  0% { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--tx), var(--ty)) scale(0); }
}
@keyframes fwStar {
  0% { transform: translate(0, 0) rotate(0deg); }
  100% { transform: translate(var(--tx), var(--ty)) rotate(360deg); }
}
