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

:root {
  --brand: #6562bc;
  --brand-dark: #5451a3;
  --brand-light: #eeedfa;
  --text: #1a1a2e;
  --text-secondary: #64748b;
  --bg: #ffffff;
  --bg-alt: #f8fafc;
  --bg-sidebar: #f1f5f9;
  --border: #e2e8f0;
  --radius: 10px;
  --max-w: 900px;
  --sidebar-w: 260px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
code { background: var(--bg-alt); padding: 2px 6px; border-radius: 4px; font-size: 0.88em; }

/* ========== Top bar ========== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  text-decoration: none;
}
.topbar-brand:hover { text-decoration: none; }
.topbar-brand img { border-radius: 6px; }
.topbar-brand em {
  font-style: normal;
  font-weight: 500;
  color: var(--brand);
}
.topbar-search {
  flex: 1;
  max-width: 380px;
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: text;
}
.topbar-search svg { color: var(--text-secondary); flex-shrink: 0; }
.topbar-search input {
  border: none;
  background: transparent;
  flex: 1;
  font-size: 0.88rem;
  color: var(--text);
  outline: none;
}
.topbar-search input::placeholder { color: var(--text-secondary); }
.topbar-search kbd {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-family: inherit;
}
.topbar-nav {
  display: flex;
  gap: 4px;
}
.topbar-nav a {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.topbar-nav a:hover, .topbar-nav a.active {
  background: var(--brand-light);
  color: var(--brand);
  text-decoration: none;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: var(--brand-light); color: var(--brand); }
.btn-secondary:hover { background: #dddaf5; }
.btn-outline { background: transparent; color: var(--brand); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--brand); background: var(--brand-light); }
.btn-white { background: #fff; color: var(--brand); }
.btn-white:hover { background: #f0f0f0; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-alt); color: var(--text); }

/* ========== Mobile menu ========== */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 4px;
}
.mobile-nav {
  display: none;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  flex-direction: column;
  gap: 4px;
}
.mobile-nav.open { display: flex; }
.mobile-nav a {
  padding: 10px 12px;
  border-radius: 6px;
  font-weight: 500;
  color: var(--text-secondary);
}
.mobile-nav a:hover { background: var(--brand-light); color: var(--brand); text-decoration: none; }

@media (max-width: 768px) {
  .topbar-nav { display: none; }
  .topbar-actions .btn { display: none; }
  .mobile-menu-btn { display: block; }
  .topbar-search { max-width: 200px; }
  .topbar-search kbd { display: none; }
}
@media (max-width: 480px) {
  .topbar-search { display: none; }
}

/* ========== Search overlay ========== */
.search-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  justify-content: center;
  padding-top: 80px;
}
.search-overlay.open { display: flex; }
.search-modal {
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.search-modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.search-modal-header svg { color: var(--text-secondary); flex-shrink: 0; }
.search-modal-header input {
  flex: 1;
  border: none;
  font-size: 1rem;
  outline: none;
  color: var(--text);
}
.search-modal-header kbd {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: inherit;
}
.search-results {
  overflow-y: auto;
  padding: 12px;
  flex: 1;
}
.search-hint {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  padding: 32px 0;
}
.search-result-item {
  display: block;
  padding: 12px 16px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  transition: background 0.1s;
}
.search-result-item:hover {
  background: var(--brand-light);
  text-decoration: none;
}
.search-result-item h4 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 2px;
}
.search-result-item p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0;
}
.search-result-item .search-category {
  font-size: 0.72rem;
  color: var(--brand);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.search-no-results {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  padding: 32px 0;
}

/* ========== Home page ========== */
.hero {
  background: linear-gradient(135deg, var(--brand) 0%, #7c79d4 100%);
  color: #fff;
  padding: 80px 24px 72px;
  text-align: center;
}
.hero-inner {
  max-width: 640px;
  margin: 0 auto;
}
.hero h1 {
  font-size: 2.4rem;
  font-weight: 800;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}
.hero p {
  font-size: 1.1rem;
  opacity: 0.92;
  margin-bottom: 32px;
  line-height: 1.6;
}
.hero-cta {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.hero .btn-primary { background: #fff; color: var(--brand); }
.hero .btn-primary:hover { background: #f0f0f0; }
.hero .btn-secondary { background: rgba(255,255,255,0.15); color: #fff; border: 1.5px solid rgba(255,255,255,0.3); }
.hero .btn-secondary:hover { background: rgba(255,255,255,0.25); }

.categories {
  padding: 48px 24px;
  background: var(--bg-alt);
}
.categories-inner {
  max-width: 1000px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}
.category-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  transition: all 0.2s;
  text-decoration: none;
  color: var(--text);
}
.category-card:hover {
  border-color: var(--brand);
  box-shadow: 0 4px 20px rgba(101,98,188,0.1);
  transform: translateY(-2px);
  text-decoration: none;
}
.category-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.category-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.category-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

.popular {
  padding: 48px 24px 64px;
}
.popular-inner {
  max-width: 700px;
  margin: 0 auto;
}
.popular h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 20px;
}
.article-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.article-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  color: var(--text);
  font-weight: 500;
  font-size: 0.92rem;
  transition: all 0.1s;
}
.article-link:hover {
  background: var(--brand-light);
  color: var(--brand);
  text-decoration: none;
}
.article-link svg { color: var(--text-secondary); flex-shrink: 0; }

/* ========== Article pages ========== */
.page-layout {
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  min-height: calc(100vh - 56px);
}
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 28px 20px;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  background: var(--bg);
}
.sidebar-section {
  margin-bottom: 28px;
}
.sidebar-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 8px;
  padding: 0 12px;
}
.sidebar a {
  display: block;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.86rem;
  color: var(--text-secondary);
  font-weight: 500;
  transition: all 0.12s;
  margin-bottom: 1px;
}
.sidebar a:hover { background: var(--brand-light); color: var(--brand); text-decoration: none; }
.sidebar a.active { background: var(--brand-light); color: var(--brand); font-weight: 600; }

.article {
  flex: 1;
  min-width: 0;
  padding: 40px 48px 80px;
  max-width: var(--max-w);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
}
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--brand); }

.article h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}
.article .subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
  line-height: 1.6;
}
.article h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 40px 0 16px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.article h2:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.article h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 28px 0 12px;
}
.article p {
  margin-bottom: 16px;
  color: var(--text);
}
.article ol, .article ul {
  margin-bottom: 16px;
  padding-left: 24px;
}
.article li { margin-bottom: 8px; }

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--brand);
  color: #fff;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.9rem;
  margin-right: 10px;
  vertical-align: middle;
}

.screenshot {
  margin: 20px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}
.screenshot img { border-radius: 0; }
.screenshot-caption {
  padding: 10px 16px;
  background: var(--bg-alt);
  font-size: 0.82rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
}

.tip {
  background: var(--brand-light);
  border-left: 4px solid var(--brand);
  padding: 14px 18px;
  border-radius: 0 8px 8px 0;
  margin: 16px 0;
  font-size: 0.9rem;
}
.tip strong { color: var(--brand-dark); }

.warning {
  background: #fef3c7;
  border-left: 4px solid #d97706;
  padding: 14px 18px;
  border-radius: 0 8px 8px 0;
  margin: 16px 0;
  font-size: 0.9rem;
}
.warning strong { color: #92400e; }

.info-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 20px 0;
}
.info-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.info-card h4 {
  font-size: 1rem;
  margin-bottom: 6px;
}
.info-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin: 0;
}

.cta-install {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 8px;
}

/* On-page TOC (right rail) */
.toc-rail {
  width: 200px;
  flex-shrink: 0;
  padding: 28px 16px;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
}
.toc-rail h4 {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.toc-rail a {
  display: block;
  padding: 4px 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
  border-left: 2px solid transparent;
  padding-left: 12px;
  margin-bottom: 2px;
}
.toc-rail a:hover { color: var(--brand); text-decoration: none; }
.toc-rail a.active { color: var(--brand); border-left-color: var(--brand); font-weight: 600; }

/* ========== Footer ========== */
.footer {
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  padding: 32px 24px;
  text-align: center;
}
.footer-inner { max-width: 800px; margin: 0 auto; }
.footer-links {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.footer-links a { font-weight: 600; font-size: 0.85rem; }
.footer-links .dot { color: var(--text-secondary); }
.footer-copy { color: var(--text-secondary); font-size: 0.78rem; }

/* ========== Responsive ========== */
@media (max-width: 1024px) {
  .toc-rail { display: none; }
}
@media (max-width: 768px) {
  .sidebar { display: none; }
  .article { padding: 24px 20px 60px; }
  .hero { padding: 48px 20px 40px; }
  .hero h1 { font-size: 1.7rem; }
  .article h1 { font-size: 1.5rem; }
}
