*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #1e293b;
  background: #f1f5f9;
  line-height: 1.6;
}
a { color: var(--primary, #2563eb); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 1.25rem; }

.site-header {
  background: var(--header-bg, #fff);
  border-bottom: 1px solid #e2e8f0;
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.header-inner { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .75rem; font-weight: 700; font-size: 1.25rem; color: #0f172a; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-logo { height: 36px; width: auto; }
.site-subtitle { margin: 0; color: #64748b; font-size: .9rem; }

.site-main { padding: 2rem 0 3rem; min-height: 60vh; }
.site-footer { background: #fff; border-top: 1px solid #e2e8f0; padding: 1.5rem 0; text-align: center; color: #64748b; font-size: .875rem; }

.hero { text-align: center; margin-bottom: 2.5rem; }
.hero h1 { font-size: 1.75rem; margin: 0 0 .5rem; color: #0f172a; }
.hero p { color: #64748b; margin: 0; }

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}
.product-card {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid #e2e8f0;
  transition: box-shadow .2s, transform .2s;
  display: block;
  color: inherit;
  text-decoration: none;
}
.product-card:hover {
  box-shadow: 0 8px 24px rgba(37, 99, 235, .12);
  transform: translateY(-2px);
  text-decoration: none;
}
.product-card h2 { margin: 0 0 .5rem; font-size: 1.15rem; color: var(--primary); }
.product-card p { margin: 0; color: #64748b; font-size: .9rem; }
.product-card .meta { margin-top: 1rem; font-size: .8rem; color: #94a3b8; }

.layout-with-sidebar {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.5rem;
  max-width: var(--content-max, 960px);
  margin: 0 auto;
  padding: 0 1.25rem;
}
@media (max-width: 768px) {
  .layout-with-sidebar {
    display: block;
    max-width: var(--content-max, 960px);
  }
}

/* 手机端：教程目录折叠为底部抽屉，正文优先展示 */
.tutorial-mobile-nav { display: none; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .75rem;
}
.sidebar-header h3 { margin: 0; }
.sidebar-close {
  display: none;
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: #e2e8f0;
  color: #475569;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.sidebar-close:hover { background: #cbd5e1; }
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  z-index: 150;
  opacity: 0;
  transition: opacity .25s ease;
}
.sidebar-backdrop.is-visible {
  display: block;
  opacity: 1;
}

@media (max-width: 768px) {
  .page-tutorial .tutorial-mobile-nav {
    display: block;
    max-width: var(--content-max, 960px);
    margin: 0 auto .75rem;
    padding: 0 1.25rem;
    position: sticky;
    top: 4.5rem;
    z-index: 90;
  }
  .sidebar-toggle {
    display: flex;
    align-items: center;
    gap: .75rem;
    width: 100%;
    padding: .75rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    color: #334155;
    font: inherit;
    text-align: left;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .06);
  }
  .sidebar-toggle:hover { background: #f8fafc; }
  .sidebar-toggle-icon {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 1rem;
  }
  .sidebar-toggle-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: .1rem;
  }
  .sidebar-toggle-label {
    font-weight: 600;
    font-size: .95rem;
    color: #0f172a;
  }
  .sidebar-toggle-meta {
    font-size: .8rem;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .sidebar-toggle-chevron {
    flex-shrink: 0;
    color: #94a3b8;
    font-size: .85rem;
    transition: transform .2s ease;
  }
  .sidebar-toggle[aria-expanded="true"] .sidebar-toggle-chevron {
    transform: rotate(180deg);
  }

  .layout-with-sidebar .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 160;
    display: flex;
    flex-direction: column;
    /* 必须设置实际高度；仅设置 max-height 时，目录较少会收缩成底部的一小条。 */
    height: min(76vh, 600px);
    height: min(76dvh, 600px);
    max-height: calc(100vh - 1rem);
    max-height: calc(100dvh - 1rem);
    margin: 0;
    padding: 0;
    border-radius: 16px 16px 0 0;
    border-bottom: none;
    box-shadow: 0 -8px 32px rgba(15, 23, 42, .18);
    overflow: hidden;
    transform: translateY(100%);
    transition: transform .28s ease;
    visibility: hidden;
  }
  .layout-with-sidebar .sidebar.is-open {
    transform: translateY(0);
    visibility: visible;
  }
  .layout-with-sidebar .sidebar-close { display: block; }
  .layout-with-sidebar .sidebar-header {
    flex-shrink: 0;
    margin: 0;
    padding: 1rem 1rem .75rem;
    background: var(--sidebar-bg, #f8fafc);
    border-bottom: 1px solid #e2e8f0;
    border-radius: 16px 16px 0 0;
  }
  .layout-with-sidebar .sidebar ul {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: .5rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
  }

  .page-tutorial .content-panel {
    padding: 1.25rem;
  }
  .page-tutorial .content-panel h1 {
    font-size: 1.35rem;
  }
}

.sidebar {
  background: var(--sidebar-bg, #f8fafc);
  border-radius: 12px;
  padding: 1rem;
  border: 1px solid #e2e8f0;
  height: fit-content;
  position: sticky;
  top: 5rem;
}
.sidebar h3 { margin: 0 0 .75rem; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: #64748b; }
.sidebar-header h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: #64748b; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li { margin: .25rem 0; }
.sidebar a {
  display: block;
  padding: .5rem .75rem;
  border-radius: 8px;
  color: #334155;
  font-size: .9rem;
}
.sidebar a:hover { background: #fff; text-decoration: none; }
.sidebar a.active { background: var(--primary); color: #fff; }

.breadcrumb { font-size: .85rem; color: #64748b; margin-bottom: 1rem; }
.breadcrumb a { color: #64748b; }

.content-panel {
  background: #fff;
  border-radius: 12px;
  padding: 2rem;
  border: 1px solid #e2e8f0;
  max-width: 100%;
}
.content-panel h1 { margin-top: 0; font-size: 1.6rem; color: #0f172a; }
.content-panel .excerpt { color: #64748b; margin-bottom: 1.5rem; }
.tutorial-body { font-size: 1rem; }
.tutorial-body img { max-width: 100%; height: auto; border-radius: 8px; }
.tutorial-body video {
  max-width: 100%;
  width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1rem 0;
  background: #0f172a;
}
.tutorial-body iframe {
  max-width: 100%;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 240px;
  border: none;
  border-radius: 8px;
  margin: 1rem 0;
  background: #0f172a;
}
.tutorial-body .mce-object-iframe,
.tutorial-body figure { margin: 1rem 0; }
.tutorial-body h2, .tutorial-body h3 { margin-top: 1.5rem; color: #0f172a; }
.tutorial-body pre, .tutorial-body code {
  background: #f1f5f9;
  border-radius: 6px;
  font-family: Consolas, monospace;
}
.tutorial-body pre { padding: 1rem; overflow-x: auto; }
.tutorial-body blockquote {
  border-left: 4px solid var(--accent);
  margin: 1rem 0;
  padding: .5rem 1rem;
  background: #f8fafc;
  color: #475569;
}

.tutorial-list { list-style: none; padding: 0; margin: 0; }
.tutorial-list li {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  margin-bottom: .75rem;
}
.tutorial-list a {
  display: block;
  padding: 1rem 1.25rem;
  color: inherit;
  text-decoration: none;
}
.tutorial-list a:hover { background: #f8fafc; text-decoration: none; }
.tutorial-list h3 { margin: 0 0 .25rem; font-size: 1.05rem; color: var(--primary); }
.tutorial-list p { margin: 0; font-size: .875rem; color: #64748b; }

.empty-state {
  text-align: center;
  padding: 3rem;
  color: #94a3b8;
  background: #fff;
  border-radius: 12px;
  border: 1px dashed #cbd5e1;
}
