@import url('../fonts/inter.css');

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

:root {
  --black:   #0a0a0a;
  --gray-900:#171717;
  --gray-800:#262626;
  --gray-700:#404040;
  --gray-600:#525252;
  --gray-500:#737373;
  --gray-400:#a3a3a3;
  --gray-300:#d4d4d4;
  --gray-200:#e5e5e5;
  --gray-100:#f5f5f5;
  --gray-50: #fafafa;
  --white:   #ffffff;

  /* Neumorphism shadows (light bg) */
  --neu-out: 6px 6px 14px #d1d1d1, -6px -6px 14px #ffffff;
  --neu-in:  inset 4px 4px 10px #d1d1d1, inset -4px -4px 10px #ffffff;
  --neu-sm:  3px 3px 8px #d4d4d4, -3px -3px 8px #ffffff;

  /* Glass */
  --glass-bg:     rgba(255,255,255,0.72);
  --glass-border: rgba(255,255,255,0.5);
  --glass-blur:   blur(16px);

  --sidebar-w: clamp(240px, 15vw, 300px);
  --topbar-h:  56px;
  --radius:    10px;
  --radius-lg: 16px;
  --transition: 0.2s cubic-bezier(.4,0,.2,1);
}

html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* ── Page loader ──────────────────────────────────────────────────────── */
#page-loader {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--white);
  display: flex; align-items: center; justify-content: center;
  transition: opacity .4s, visibility .4s;
}
#page-loader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-ring {
  width: 40px; height: 40px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--black);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Progress bar ─────────────────────────────────────────────────────── */
#nprogress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, #6ea8fe, #a78bfa, #c084fc); z-index: 10000;
  transform-origin: left;
  transition: transform .3s ease;
}

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

/* ── Sidebar ──────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  position: fixed; top: 0; left: 0; bottom: 0;
  overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column;
  z-index: 200;
  box-shadow: var(--neu-sm);
  transition: transform var(--transition);
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 2px; }

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo a {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--gray-900);
  font-size: 15px; font-weight: 700; letter-spacing: -.3px;
}
.logo-img {
  width: 28px; height: 28px; border-radius: 6px;
  object-fit: contain;
  box-shadow: var(--neu-sm);
}
.logo-placeholder {
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--black); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
  box-shadow: var(--neu-sm);
  flex-shrink: 0;
}

.sidebar-search { padding: 12px 14px; }
.sidebar-search-inner {
  display: flex; align-items: center; gap: 8px;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 8px; padding: 7px 12px;
  box-shadow: var(--neu-in);
  transition: box-shadow var(--transition);
}
.sidebar-search-inner:focus-within {
  box-shadow: var(--neu-in), 0 0 0 2px var(--black);
}
.sidebar-search-inner svg { color: var(--gray-400); flex-shrink: 0; }
.sidebar-search-inner input {
  border: none; background: transparent; outline: none;
  font-size: 13px; color: var(--gray-900); width: 100%;
  font-family: inherit;
}
.sidebar-search-inner input::placeholder { color: var(--gray-400); }

.sidebar-nav { flex: 1; padding: 8px 0 20px; }
.cat-list, .cat-children { list-style: none; }
.cat-children { padding-left: 14px; display: none; }
.cat-item.open > .cat-children { display: block; }

.cat-link {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 18px; color: var(--gray-600); text-decoration: none;
  font-size: 13.5px; border-left: 2px solid transparent;
  transition: all var(--transition); cursor: pointer;
  border-radius: 0 6px 6px 0; margin-right: 8px;
}
.cat-link:hover { color: var(--gray-900); background: var(--gray-100); }
.cat-link.active {
  color: var(--black); border-left-color: var(--black);
  background: var(--gray-100); font-weight: 600;
}
.cat-arrow {
  width: 14px; height: 14px; transition: transform var(--transition);
  color: var(--gray-400);
}
.cat-item.open > .cat-link .cat-arrow { transform: rotate(90deg); }

/* ── Main ─────────────────────────────────────────────────────────────── */
.main { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; display: flex; flex-direction: column; }

/* ── Topbar ───────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-border);
  padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 0 var(--gray-200);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-size: 14px; font-weight: 600; color: var(--gray-700); }
.topbar-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--gray-100); border: 1px solid var(--gray-200);
  border-radius: 8px; padding: 6px 12px;
  box-shadow: var(--neu-in);
  transition: box-shadow var(--transition);
}
.topbar-search:focus-within { box-shadow: var(--neu-in), 0 0 0 2px var(--black); }
.topbar-search input {
  border: none; background: transparent; outline: none;
  font-size: 13px; width: 200px; font-family: inherit; color: var(--gray-900);
}
.topbar-search input::placeholder { color: var(--gray-400); }
.btn-search {
  padding: 5px 14px; background: var(--black); color: var(--white);
  border: none; border-radius: 6px; cursor: pointer; font-size: 12px;
  font-weight: 500; font-family: inherit;
  transition: background var(--transition), transform var(--transition);
  box-shadow: var(--neu-sm);
}
.btn-search:hover { background: var(--gray-800); transform: translateY(-1px); }
.btn-search:active { transform: translateY(0); }

.menu-toggle {
  display: none; background: none; border: none; cursor: pointer;
  padding: 6px; border-radius: 6px; color: var(--gray-700);
  transition: background var(--transition);
}
.menu-toggle:hover { background: var(--gray-100); }

/* ── Hero section ─────────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, #6ea8fe 0%, #a78bfa 50%, #c084fc 100%);
  color: var(--white);
  padding: 72px 40px 64px;
  position: relative; overflow: hidden;
  min-height: 420px; display: flex; align-items: center;
}
.hero::before {
  content: '';
  position: absolute; inset: 0; z-index: 1;
  background:
    radial-gradient(ellipse 70% 50% at 20% 30%, rgba(255,255,255,.18) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 80% 70%, rgba(167,139,250,.3) 0%, transparent 60%);
  pointer-events: none;
}
/* hero background media — fully replaces the gradient */
.hero-media {
  position: absolute; inset: 0; z-index: 0;
  pointer-events: none;
}
.hero-media img, .hero-media video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
/* when media present, dim it and overlay a dark-to-transparent scrim so text stays readable */
.hero-media::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(80,60,160,.55) 0%, rgba(40,20,100,.45) 100%);
}
/* hide the decorative radial overlay when media is present */
.hero.has-media::before { display: none; }
.hero.has-media { background: #1a0a3c; }
.hero-inner { max-width: 640px; position: relative; z-index: 2; width: 100%; }
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: rgba(255,255,255,.7); margin-bottom: 16px;
}
.hero-eyebrow-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--white); opacity: .7; }
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800; line-height: 1.15; letter-spacing: -.04em;
  margin-bottom: 16px;
  text-shadow: 0 2px 16px rgba(99,60,180,.25);
}
.hero p {
  font-size: 16px; color: rgba(255,255,255,.75);
  line-height: 1.7; margin-bottom: 28px; max-width: 480px;
}
.hero-search {
  display: flex; gap: 8px; max-width: 480px;
}
.hero-search input {
  flex: 1; padding: 12px 16px;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 8px; color: var(--white);
  font-size: 14px; font-family: inherit; outline: none;
  backdrop-filter: blur(10px);
  transition: border-color var(--transition), background var(--transition);
}
.hero-search input::placeholder { color: rgba(255,255,255,.5); }
.hero-search input:focus { border-color: rgba(255,255,255,.6); background: rgba(255,255,255,.25); }
.hero-search button {
  padding: 12px 20px; background: var(--white); color: #6d28d9;
  border: none; border-radius: 8px; cursor: pointer;
  font-size: 13px; font-weight: 700; font-family: inherit;
  transition: opacity var(--transition), transform var(--transition);
  white-space: nowrap; box-shadow: 0 2px 12px rgba(99,60,180,.2);
}
.hero-search button:hover { opacity: .92; transform: translateY(-1px); }
.hero-stats {
  display: flex; gap: 28px; margin-top: 32px;
  padding-top: 28px; border-top: 1px solid rgba(255,255,255,.2);
}
.hero-stat-value { font-size: 22px; font-weight: 800; }
.hero-stat-label { font-size: 12px; color: rgba(255,255,255,.6); margin-top: 2px; }

/* ── Content area ─────────────────────────────────────────────────────── */
.content { padding: 28px 32px; flex: 1; }
.content-header { margin-bottom: 20px; }
.content-title { font-size: 18px; font-weight: 700; letter-spacing: -.3px; }
.content-sub { font-size: 13px; color: var(--gray-500); margin-top: 3px; }

/* ── Doc grid ─────────────────────────────────────────────────────────── */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }

/* ── Category group view ──────────────────────────────────────────────── */
.cat-group-list { display: flex; flex-direction: column; gap: 32px; }
.cat-group-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gray-200);
}
.cat-group-title {
  font-size: 15px; font-weight: 700; letter-spacing: -.3px;
  color: var(--gray-900); text-decoration: none;
  transition: color var(--transition);
}
.cat-group-title:hover { color: var(--gray-600); }
.cat-group-count {
  font-size: 12px; color: var(--gray-400);
  background: var(--gray-100); border-radius: 20px;
  padding: 2px 8px;
}
.cat-group-empty { font-size: 13px; color: var(--gray-400); padding: 8px 0; }

.doc-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  text-decoration: none; color: var(--gray-900);
  box-shadow: var(--neu-out);
  transition: box-shadow var(--transition), transform var(--transition);
  cursor: pointer; display: flex; align-items: flex-start; gap: 16px;
  position: relative; overflow: hidden;
  min-height: 120px; box-sizing: border-box;
}
.doc-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--black);
  transform: scaleX(0); transform-origin: left;
  transition: transform var(--transition);
}
.doc-card:hover { box-shadow: 8px 8px 20px #c8c8c8, -8px -8px 20px #ffffff; transform: translateY(-2px); }
.doc-card:hover::before { transform: scaleX(1); }
.doc-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.doc-card-cat {
  font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--gray-500); margin-bottom: 6px; flex-shrink: 0;
}
.doc-card-title { font-size: 15px; font-weight: 600; line-height: 1.4; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-card-summary { font-size: 13px; color: var(--gray-500); line-height: 1.5; flex: 1; min-width: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.doc-card-snippet { font-size: 12.5px; color: var(--gray-500); line-height: 1.6; flex: 1; min-width: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-all; }
.search-hit { background: #fef08a; color: var(--gray-900); border-radius: 2px; padding: 0 1px; }
.doc-card-meta { font-size: 11px; color: var(--gray-400); display: flex; gap: 10px; margin-top: 10px; flex-shrink: 0; }
.doc-card-thumb { width: 90px; min-width: 90px; height: 90px; flex-shrink: 0; border-radius: 8px; overflow: hidden; align-self: center; }
.doc-card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ── Skeleton loader ──────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton-card {
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg); padding: 20px;
  box-shadow: var(--neu-out);
}
.skeleton-line { height: 12px; margin-bottom: 8px; }
.skeleton-title { height: 16px; width: 75%; margin-bottom: 12px; }
.skeleton-meta { height: 10px; width: 50%; }

/* ── Doc detail ───────────────────────────────────────────────────────── */
.doc-layout { display: flex; flex: 1; }
.doc-body { flex: 1; padding: 36px 44px; min-width: 0; overflow-x: hidden; }
.doc-toc { width: clamp(200px, 16vw, 300px); flex-shrink: 0; padding: 36px 20px 36px 0; align-self: flex-start; position: sticky; top: calc(var(--topbar-h) + 16px); max-height: calc(100vh - var(--topbar-h) - 32px); overflow-y: auto; }
.toc-sticky { }
.toc-title {
  font-size: 11px; font-weight: 700; color: var(--gray-500);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px;
}
.toc-list { list-style: none; }
.toc-list a {
  display: block; padding: 4px 0 4px 12px;
  font-size: 12.5px; color: var(--gray-500); text-decoration: none;
  border-left: 2px solid var(--gray-200);
  transition: all var(--transition);
}
.toc-list a:hover { color: var(--gray-900); border-left-color: var(--gray-400); }
.toc-list a.active { color: var(--black); border-left-color: var(--black); font-weight: 600; }
.toc-list .toc-h3 { padding-left: 22px; font-size: 12px; }

/* ── Doc content typography ───────────────────────────────────────────── */
.doc-meta {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 24px; color: var(--gray-500); font-size: 12.5px;
  padding-bottom: 16px; border-bottom: 1px solid var(--gray-200);
}
.doc-meta-tag {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--gray-100); border: 1px solid var(--gray-200);
  border-radius: 20px; padding: 3px 10px; font-size: 11.5px;
  box-shadow: var(--neu-sm);
}

.doc-content h1 { font-size: 26px; font-weight: 800; letter-spacing: -.04em; margin: 0 0 20px; padding-bottom: 12px; border-bottom: 2px solid var(--gray-200); }
.doc-content h2 { font-size: 19px; font-weight: 700; letter-spacing: -.02em; margin: 32px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--gray-200); }
.doc-content h3 { font-size: 15px; font-weight: 700; margin: 24px 0 8px; }
.doc-content p { margin: 0 0 16px; color: var(--gray-800); line-height: 1.75; }
.doc-content ul, .doc-content ol { margin: 0 0 16px 22px; }
.doc-content li { margin-bottom: 5px; color: var(--gray-800); line-height: 1.7; }
.doc-content a { color: var(--black); text-decoration: underline; text-underline-offset: 3px; }
.doc-content a:hover { opacity: .7; }
.doc-content blockquote {
  border-left: 3px solid var(--black); padding: 10px 18px;
  background: var(--gray-50); margin: 16px 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--gray-700);
  box-shadow: var(--neu-sm);
}
.doc-content code {
  background: var(--gray-100); padding: 2px 6px; border-radius: 4px;
  font-size: 13px; font-family: 'Fira Code', 'Consolas', monospace;
  border: 1px solid var(--gray-200); color: var(--gray-900);
}
.doc-content pre {
  background: var(--gray-900); border-radius: var(--radius);
  padding: 12px 14px; margin: 16px 0;
  box-shadow: var(--neu-out);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  max-width: 100%; white-space: pre; position: relative;
}
.doc-content pre code { background: none; border: none; padding: 0; color: #e5e5e5; font-size: 13px; display: block; overflow-x: auto; }
.code-copy-btn {
  position: absolute; top: 6px; right: 6px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15);
  color: #ccc; font-size: 11px; padding: 3px 8px; border-radius: 4px;
  cursor: pointer; transition: background .2s, color .2s;
}
.code-copy-btn:hover { background: rgba(255,255,255,.2); color: #fff; }
.code-copy-btn.copied { color: #68d391; }

/* ── Download card ───────────────────────────────────────────────────── */
.download-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px; margin: 14px 0; border-radius: var(--radius);
  background: var(--white); border: 1px solid var(--gray-200);
  box-shadow: 0 1px 4px rgba(0,0,0,.05); transition: box-shadow .2s, border-color .2s;
  cursor: default;
}
.download-card:hover { border-color: var(--gray-300); box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.download-card-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.download-card-icon svg { width: 22px; height: 22px; }
.download-card-info { flex: 1; min-width: 0; }
.download-card-name { font-size: 14px; font-weight: 500; color: var(--gray-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.download-card-meta { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.download-card-ext {
  font-size: 10px; font-weight: 600; letter-spacing: .04em;
  padding: 1px 5px; border-radius: 3px;
  background: var(--gray-100); color: var(--gray-500);
}
.download-card-size { font-size: 12px; color: var(--gray-400); }
.download-card-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 8px 16px; border-radius: 7px; font-size: 13px; font-weight: 500;
  background: #fff; color: var(--gray-900); text-decoration: none !important; white-space: nowrap;
  border: 1.5px solid var(--gray-900); transition: background .15s, transform .1s; flex-shrink: 0;
  cursor: pointer; font-family: inherit;
}
.download-card-btn:hover { background: var(--gray-50); transform: translateY(-1px); }

/* ── Music card ──────────────────────────────────────────────────────── */
.music-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px; margin: 14px 0; border-radius: var(--radius);
  background: var(--white); border: 1px solid var(--gray-200);
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.music-card-icon {
  width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0;
  background: #805ad522; color: #805ad5;
  display: flex; align-items: center; justify-content: center;
}
.music-card-info { flex: 1; min-width: 0; }
.music-card-title { font-size: 14px; font-weight: 600; color: var(--gray-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.music-card-artist { font-size: 12px; color: var(--gray-400); margin-top: 2px; }
.music-card-controls { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.music-play-btn {
  width: 38px; height: 38px; border-radius: 50%; border: none; cursor: pointer;
  background: #805ad5; color: #fff; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .15s, transform .1s; box-shadow: 0 2px 8px #805ad540;
}
.music-play-btn:hover { background: #6b46c1; }
.music-play-btn:active { transform: scale(.93); }
.music-play-btn svg { pointer-events: none; }
.music-progress-wrap { display: flex; align-items: center; gap: 8px; min-width: 160px; }
.music-progress-bar {
  flex: 1; height: 4px; border-radius: 99px; background: var(--gray-200);
  position: relative; cursor: pointer; overflow: visible;
}
.music-progress-fill {
  height: 100%; border-radius: 99px; background: #805ad5;
  width: 0%; pointer-events: none; transition: width .1s linear;
}
.music-progress-thumb {
  width: 12px; height: 12px; border-radius: 50%; background: #805ad5;
  position: absolute; top: 50%; transform: translate(-50%,-50%);
  left: 0%; pointer-events: none; box-shadow: 0 1px 4px #805ad560;
  opacity: 0; transition: opacity .15s;
}
.music-progress-bar:hover .music-progress-thumb { opacity: 1; }
.music-time { font-size: 11px; color: var(--gray-400); white-space: nowrap; font-variant-numeric: tabular-nums; min-width: 72px; text-align: right; }
@media (max-width: 600px) {
  .music-card { flex-wrap: wrap; }
  .music-progress-wrap { min-width: 0; flex: 1; }
  .music-card-controls { width: 100%; }
}

/* ── Video card ──────────────────────────────────────────────────────── */
.video-card {
  position: relative; margin: 14px 0; border-radius: 12px; overflow: hidden;
  background: #000; box-shadow: 0 2px 12px rgba(0,0,0,.12);
}
.video-card-player { position: relative; cursor: pointer; line-height: 0; }
.video-card-player video { width: 100%; display: block; }
.video-card-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.3); transition: background .2s;
}
.video-card-overlay:hover { background: rgba(0,0,0,.4); }
.video-overlay-btn {
  width: 52px; height: 52px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255,255,255,.92); color: #805ad5;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px); box-shadow: 0 4px 20px rgba(0,0,0,.2);
  transition: transform .15s, box-shadow .15s;
}
.video-overlay-btn:hover { transform: scale(1.06); box-shadow: 0 6px 24px rgba(0,0,0,.3); }
.video-overlay-btn svg { margin-left: 2px; }
.video-card-controls {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: linear-gradient(transparent, rgba(0,0,0,.7));
  opacity: 1; transition: opacity .3s;
}
.video-card.playing .video-card-controls { opacity: 0; }
.video-card.playing:hover .video-card-controls { opacity: 1; }
.video-play-btn {
  width: 28px; height: 28px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255,255,255,.15); color: #fff; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .15s; backdrop-filter: blur(4px);
}
.video-play-btn:hover { background: rgba(255,255,255,.25); }
.video-play-btn svg { pointer-events: none; }
.video-time { font-size: 11px; color: rgba(255,255,255,.7); white-space: nowrap; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.video-progress-bar {
  flex: 1; height: 3px; border-radius: 99px; background: rgba(255,255,255,.2);
  position: relative; cursor: pointer; overflow: visible; transition: height .15s;
}
.video-card-controls:hover .video-progress-bar { height: 5px; }
.video-progress-fill {
  height: 100%; border-radius: 99px; background: #805ad5;
  width: 0%; pointer-events: none; transition: width .1s linear;
}
.video-progress-thumb {
  width: 12px; height: 12px; border-radius: 50%; background: #fff;
  position: absolute; top: 50%; transform: translate(-50%,-50%);
  left: 0%; pointer-events: none; box-shadow: 0 0 6px rgba(0,0,0,.3);
  opacity: 0; transition: opacity .15s;
}
.video-card-controls:hover .video-progress-thumb { opacity: 1; }
.video-fullscreen-btn {
  background: none; border: none; color: rgba(255,255,255,.6); cursor: pointer;
  padding: 4px; display: flex; align-items: center; flex-shrink: 0; transition: color .15s;
}
.video-fullscreen-btn:hover { color: #fff; }
.video-card:fullscreen { background: #000; border-radius: 0; }
.video-card:fullscreen .video-card-player video { height: 100vh; object-fit: contain; }
.video-card:fullscreen .video-card-controls { opacity: 0; }
.video-card:fullscreen:hover .video-card-controls { opacity: 1; }

.doc-content img { max-width: 100%; width: auto; height: auto; display: block; border-radius: var(--radius); margin: 8px 0; box-shadow: var(--neu-out); }
.doc-content video { max-width: 100%; width: 100%; height: auto; display: block; }
.doc-content img, .doc-content video { box-sizing: border-box; }
.doc-content table { width: 100%; border-collapse: collapse; margin: 16px 0; }
.doc-content .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.doc-content th, .doc-content td { border: 1px solid var(--gray-200); padding: 9px 14px; text-align: left; font-size: 14px; }
.doc-content th { background: var(--gray-50); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--gray-600); }
.doc-content hr { border: none; border-top: 1px solid var(--gray-200); margin: 28px 0; }

/* ── Doc nav ──────────────────────────────────────────────────────────── */
.doc-nav {
  display: flex; justify-content: space-between; gap: 14px;
  margin-top: 44px; padding-top: 24px; border-top: 1px solid var(--gray-200);
}
.doc-nav a {
  flex: 1; padding: 16px 20px;
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg); text-decoration: none; color: var(--gray-900);
  box-shadow: var(--neu-out);
  transition: box-shadow var(--transition), transform var(--transition);
  cursor: pointer;
}
.doc-nav a:hover { box-shadow: 6px 6px 16px #c8c8c8, -6px -6px 16px #ffffff; transform: translateY(-1px); }
.nav-label { font-size: 11px; color: var(--gray-400); margin-bottom: 5px; font-weight: 500; }
.nav-title { font-size: 13.5px; font-weight: 600; }
.nav-next { text-align: right; }

/* ── Content fade-in animation ────────────────────────────────────────── */
.fade-in { animation: fadeIn .35s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.slide-in { animation: slideIn .3s ease both; }
@keyframes slideIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: translateX(0); } }

/* ── Glass card ───────────────────────────────────────────────────────── */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--neu-out);
}

/* ── Empty state ──────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--gray-400);
}
.empty-state-icon {
  width: 48px; height: 48px; margin: 0 auto 14px;
  background: var(--gray-100); border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--neu-out);
}
.empty-state p { font-size: 14px; }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .doc-toc { display: none; }
  .doc-body { padding: 28px 32px; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.15); }
  .main { margin-left: 0; }
  .menu-toggle { display: flex; }
  .hero { padding: 48px 20px 40px; min-height: 320px; }
  .content { padding: 20px; }
  .doc-body { padding: 20px; overflow-x: hidden; }
  .doc-content { overflow-x: hidden; }
  .doc-content pre { font-size: 12.5px; padding: 10px 12px; border-radius: 6px; max-width: calc(100vw - 32px); }
  .topbar { padding: 0 16px; }
  .topbar-search { display: none; }
  .doc-grid { grid-template-columns: 1fr; }
}

/* ── Sidebar overlay (mobile) ─────────────────────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 199; backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ── Reduced motion ───────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── GeeTest captcha overlay ─────────────────────────────────────────── */
.gt-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,.55); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  animation: gt-fade-in .2s ease;
}
@keyframes gt-fade-in { from { opacity: 0; } to { opacity: 1; } }
.gt-modal {
  position: relative; background: var(--white); border-radius: 14px;
  padding: 28px 28px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
  min-width: 320px; max-width: 90vw;
  animation: gt-slide-up .22s ease;
}
@keyframes gt-slide-up { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.gt-modal-title {
  font-size: 15px; font-weight: 600; color: var(--gray-900);
  margin-bottom: 18px; text-align: center;
}
.gt-modal-close {
  position: absolute; top: 12px; right: 14px;
  background: none; border: none; font-size: 18px; color: var(--gray-400);
  cursor: pointer; line-height: 1; padding: 4px;
}
.gt-modal-close:hover { color: var(--gray-900); }
#gt-box { display: flex; justify-content: center; }

/* ── AI Dialog ───────────────────────────────────────────────────────── */
.ai-trigger-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 10px; border: none;
  background: linear-gradient(135deg, #a78bfa 0%, #818cf8 50%, #6366f1 100%);
  color: #fff; cursor: pointer; flex-shrink: 0; position: relative;
  transition: transform .2s, box-shadow .2s;
}
.ai-trigger-btn:hover { transform: scale(1.08); box-shadow: 0 0 16px rgba(99,102,241,.4); }
.ai-trigger-btn svg { width: 18px; height: 18px; }
.ai-trigger-btn::after {
  content: ''; position: absolute; inset: -2px; border-radius: 12px;
  background: linear-gradient(135deg, #a78bfa, #6366f1);
  opacity: 0; z-index: -1; animation: ai-glow 2s ease-in-out infinite;
}
@keyframes ai-glow { 0%,100% { opacity: 0; transform: scale(1); } 50% { opacity: .3; transform: scale(1.15); } }

.ai-dialog-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 9998;
  opacity: 0; transition: opacity .3s; pointer-events: none;
  backdrop-filter: blur(2px);
}
.ai-dialog-overlay.active { opacity: 1; pointer-events: auto; }

.ai-dialog {
  position: fixed; z-index: 9999;
  width: 92vw; max-width: 640px; height: 80vh; max-height: 700px;
  top: 50%; left: 50%; transform: translate(-50%, -50%) scale(.3);
  background: #fff; border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0,0,0,.18);
  display: flex; flex-direction: column;
  visibility: hidden; pointer-events: none;
  transition: transform .4s cubic-bezier(.34,1.56,.64,1), visibility 0s .4s;
  overflow: hidden;
}
.ai-dialog.active { visibility: visible; pointer-events: auto; transform: translate(-50%, -50%) scale(1); transition: transform .4s cubic-bezier(.34,1.56,.64,1), visibility 0s; }
.ai-dialog.closing { transform: translate(-50%, -50%) scale(.3); visibility: hidden; transition: transform .25s ease-in, visibility 0s .25s; }

.ai-dialog-header {
  display: flex; align-items: center; padding: 14px 18px; gap: 10px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(99,102,241,.06), rgba(167,139,250,.06));
}
.ai-dialog-header .ai-header-icon {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, #a78bfa, #6366f1);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ai-dialog-header .ai-header-icon svg { width: 16px; height: 16px; color: #fff; }
.ai-dialog-header .ai-header-title { font-size: 14px; font-weight: 600; flex: 1; color: var(--gray-900); }
.ai-dialog-header button {
  background: none; border: none; cursor: pointer; padding: 4px;
  color: var(--gray-400); border-radius: 6px; transition: background .15s, color .15s;
}
.ai-dialog-header button:hover { background: var(--gray-100); color: var(--gray-700); }

.ai-messages {
  flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 16px;
  scroll-behavior: smooth;
}
.ai-messages::-webkit-scrollbar { width: 4px; }
.ai-messages::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 4px; }

.ai-msg { display: flex; gap: 10px; max-width: 92%; min-width: 0; flex-shrink: 0; animation: ai-msg-in .3s ease; }
.ai-msg-user { align-self: flex-end; flex-direction: row-reverse; }
@keyframes ai-msg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.ai-msg-avatar {
  width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.ai-msg-ai .ai-msg-avatar { background: linear-gradient(135deg, #a78bfa, #6366f1); color: #fff; }
.ai-msg-user .ai-msg-avatar { background: var(--gray-200); color: var(--gray-600); }

.ai-msg-bubble {
  padding: 10px 14px; border-radius: 12px; font-size: 13.5px; line-height: 1.65;
  word-break: break-word; min-width: 0; overflow: hidden;
}
.ai-msg-ai .ai-msg-bubble { background: var(--gray-50); color: var(--gray-800); border-top-left-radius: 4px; }
.ai-msg-user .ai-msg-bubble { background: #6366f1; color: #fff; border-top-right-radius: 4px; }
.ai-msg-bubble p { margin: 0 0 6px; }
.ai-msg-bubble p:last-child { margin-bottom: 0; }
.ai-msg-bubble code { font-size: 12px; background: rgba(0,0,0,.06); padding: 1px 4px; border-radius: 3px; word-break: break-all; }
.ai-msg-bubble pre { margin: 8px 0; border-radius: 8px; overflow-x: auto; max-width: 100%; }
.ai-msg-bubble pre code { display: block; padding: 10px 12px; background: var(--gray-900); color: #e2e8f0; font-size: 12px; word-break: normal; white-space: pre; }

.ai-ref-cards { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; padding-bottom: 4px; flex-shrink: 0; min-height: fit-content; }
.ai-ref-cards::-webkit-scrollbar { height: 3px; }
.ai-ref-cards::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 3px; }
.ai-ref-card {
  flex-shrink: 0; width: 200px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: #fff;
  text-decoration: none; color: var(--gray-700);
  transition: border-color .15s, box-shadow .15s; cursor: pointer;
}
.ai-ref-card:hover { border-color: #818cf8; box-shadow: 0 2px 12px rgba(99,102,241,.12); }
.ai-ref-card-title { font-size: 12.5px; font-weight: 600; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--gray-800); }
.ai-ref-card-snippet { font-size: 11.5px; color: var(--gray-500); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ai-ref-card-icon { font-size: 10px; color: #818cf8; margin-top: 4px; }

.ai-input-area {
  display: flex; gap: 8px; padding: 14px 18px;
  border-top: 1px solid var(--border); background: #fff;
}
.ai-input-area input {
  flex: 1; border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 14px; font-size: 13.5px; outline: none;
  background: var(--gray-50); color: var(--gray-800);
  transition: border-color .15s;
}
.ai-input-area input:focus { border-color: #818cf8; }
.ai-input-area input::placeholder { color: var(--gray-400); }
.ai-send-btn {
  width: 38px; height: 38px; border-radius: 10px; border: none;
  background: linear-gradient(135deg, #818cf8, #6366f1);
  color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: transform .15s, opacity .15s; flex-shrink: 0;
}
.ai-send-btn:hover { transform: scale(1.06); }
.ai-send-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.ai-send-btn svg { width: 16px; height: 16px; }

.ai-typing-indicator { display: flex; gap: 4px; padding: 4px 0; }
.ai-typing-indicator span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--gray-400);
  animation: ai-typing .8s ease-in-out infinite;
}
.ai-typing-indicator span:nth-child(2) { animation-delay: .15s; }
.ai-typing-indicator span:nth-child(3) { animation-delay: .3s; }
@keyframes ai-typing { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-4px); } }

.ai-welcome { text-align: center; padding: 30px 20px; color: var(--gray-500); }
.ai-welcome-icon {
  width: 48px; height: 48px; border-radius: 14px; margin: 0 auto 12px;
  background: linear-gradient(135deg, rgba(99,102,241,.1), rgba(167,139,250,.1));
  display: flex; align-items: center; justify-content: center;
}
.ai-welcome-icon svg { width: 24px; height: 24px; color: #6366f1; }
.ai-welcome-text { font-size: 13px; line-height: 1.6; }

@media (max-width: 640px) {
  .ai-dialog { width: auto; height: auto; max-width: none; max-height: none; border-radius: 0; inset: 0; transform: translateY(100%); }
  .ai-dialog.active { transform: translateY(0); }
  .ai-dialog.closing { transform: translateY(100%); }
  .ai-ref-card { width: 160px; }
}

/* ── Toast & Confirm Modal ───────────────────────────────────────────── */
.ds-toast{position:fixed;top:24px;left:50%;transform:translateX(-50%) translateY(-20px);background:var(--gray-900);color:#fff;padding:10px 24px;border-radius:10px;font-size:14px;z-index:1000010;opacity:0;pointer-events:none;transition:opacity .25s,transform .25s;box-shadow:0 4px 20px rgba(0,0,0,.2);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;}
.ds-toast.ds-show{opacity:1;transform:translateX(-50%) translateY(0);pointer-events:auto;}
.ds-modal-mask{position:fixed;inset:0;background:rgba(0,0,0,.4);z-index:1000010;display:flex;align-items:center;justify-content:center;opacity:0;pointer-events:none;transition:opacity .2s;}
.ds-modal-mask.ds-show{opacity:1;pointer-events:auto;}
.ds-modal{background:#fff;border-radius:14px;padding:28px 24px 20px;width:340px;max-width:calc(100vw - 40px);box-shadow:0 12px 40px rgba(0,0,0,.18);text-align:center;transform:scale(.9);transition:transform .25s;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;}
.ds-modal-mask.ds-show .ds-modal{transform:scale(1);}
.ds-modal-msg{font-size:15px;color:var(--gray-800);line-height:1.6;margin-bottom:20px;}
.ds-modal-btns{display:flex;gap:10px;justify-content:center;}
.ds-modal-btns button{flex:1;padding:8px 0;border-radius:8px;border:none;font-size:14px;cursor:pointer;transition:background .15s;}
.ds-modal-btn-cancel{background:var(--gray-100);color:var(--gray-700);}
.ds-modal-btn-cancel:hover{background:var(--gray-200);}
.ds-modal-btn-ok{background:var(--gray-900);color:#fff;}
.ds-modal-btn-ok:hover{background:var(--gray-800);}
