:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  --primary: #1688f8;
  --primary-dark: #0875df;
  --text-strong: #17233d;
  --text: #40516c;
  --text-muted: #66758b;
  --border: #dfe7f0;
  --surface-soft: #f4f8fc;
  --shadow: 0 10px 24px rgba(31, 92, 143, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--surface-soft);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--surface-soft);
}

body.drawer-open {
  overflow: hidden;
}

button {
  font: inherit;
}

button:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(22, 136, 248, 0.3);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.page {
  min-height: 100vh;
  padding: 20px 22px;
}

.guide-content {
  min-height: calc(100vh - 40px);
  padding: 20px;
  background: #fff;
  border: 1px solid #e5edf5;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(37, 76, 122, 0.04);
}

.page-nav {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #edf1f5;
}

.page-nav h1 {
  margin: 0;
  color: var(--text-strong);
  font-size: 1.35rem;
}

.back-link {
  position: absolute;
  left: 0;
  display: inline-flex;
  align-items: center;
  color: var(--primary);
  font-size: .94rem;
  text-decoration: none;
}

.back-link:hover { color: var(--primary-dark); }
.back-link:focus-visible { outline: 3px solid rgba(22, 136, 248, 0.3); outline-offset: 3px; }
.back-link svg { width: 18px; margin-right: 3px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.category-tabs,
.drawer-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.category-tabs {
  margin-bottom: 28px;
}

.category-tab {
  min-width: 110px;
  height: 40px;
  padding: 0 24px;
  color: #53627a;
  font-size: 1rem;
  background: #f8fafc;
  border: 1px solid #e3eaf2;
  border-radius: 5px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.category-tab:hover {
  color: var(--primary-dark);
  border-color: #9dccfa;
}

.category-tab.active {
  color: #fff;
  font-weight: 600;
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 4px 10px rgba(22, 136, 248, 0.18);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-heading h2 {
  margin: 0;
  color: var(--text-strong);
  font-size: 1.375rem;
  line-height: 2rem;
}

.text-button {
  padding: 6px 0;
  color: var(--primary);
  font-size: 1rem;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.text-button:hover {
  color: #006ed6;
}

.tutorial-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  min-height: 145px;
}

.tutorial-card {
  display: grid;
  grid-template-columns: 42% minmax(0, 1fr);
  align-items: center;
  min-width: 0;
  min-height: 145px;
  padding: 12px;
  text-align: left;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.tutorial-card:hover {
  transform: translateY(-2px);
  border-color: #acd4fa;
  box-shadow: var(--shadow);
}

.tutorial-cover {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background-color: #e6f3ff;
  background-position: center;
  background-size: cover;
  border-radius: 7px;
}

.tutorial-cover.is-placeholder {
  background:
    radial-gradient(circle at 28% 35%, rgba(255, 255, 255, 0.94), transparent 23%),
    linear-gradient(135deg, #eaf6ff, #d7ebff);
}

.cover-mark {
  position: absolute;
  right: 16%;
  bottom: 18%;
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 45%;
}

.cover-mark i {
  display: block;
  width: 7px;
  background: rgba(22, 136, 248, 0.3);
  border-radius: 4px 4px 1px 1px;
}

.cover-mark i:nth-child(1) { height: 52%; }
.cover-mark i:nth-child(2) { height: 100%; }
.cover-mark i:nth-child(3) { height: 75%; }

.tutorial-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-left: 16px;
}

.tutorial-info strong {
  overflow: hidden;
  color: var(--text-strong);
  font-size: 1.0625rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tutorial-info span {
  display: -webkit-box;
  margin-top: 8px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.qa-section {
  margin-top: 34px;
}

.qa-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.qa-panel {
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 7px;
}

.qa-panel-heading {
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 0 18px;
  background: linear-gradient(90deg, #f1f7fd, #fff);
}

.qa-panel-heading h3 {
  margin: 0 0 0 12px;
  color: #24344f;
  font-size: 1.0625rem;
  font-weight: 600;
}

.qa-panel-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  color: var(--primary);
  background: #e7f3ff;
  border-radius: 6px;
}

.qa-panel-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.qa-list {
  min-height: 210px;
  padding: 0 18px;
}

.qa-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 42px;
  padding: 8px 0;
  color: var(--text);
  font-size: 0.9375rem;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid #e1e8f0;
  cursor: pointer;
}

.qa-item:last-child {
  border-bottom: 0;
}

.qa-item:hover {
  color: var(--primary-dark);
}

.qa-item svg,
.card-arrow {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-left: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.loading-state,
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 145px;
  color: #8793a5;
  font-size: 0.9375rem;
}

.tutorial-grid > .loading-state,
.tutorial-grid > .empty-state {
  grid-column: 1 / -1;
}

.qa-list .loading-state,
.qa-list .empty-state {
  min-height: 210px;
}

.empty-state {
  flex-direction: column;
}

.empty-state p {
  margin: 10px 0 0;
}

.empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  color: #9eb0c3;
  font-size: 1.4rem;
  font-weight: 600;
  background: #f1f6fa;
  border: 1px solid #e1eaf2;
  border-radius: 50%;
}

.spinner {
  width: 20px;
  height: 20px;
  margin-right: 10px;
  border: 2px solid #d8eaff;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.drawer-layer {
  position: fixed;
  z-index: 1000;
  inset: 0;
}

.drawer-layer[hidden] {
  display: none;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 35, 54, 0.46);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.drawer {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  width: min(720px, 50vw);
  min-width: 560px;
  height: 100%;
  background: #f8fbfe;
  box-shadow: -12px 0 36px rgba(18, 52, 86, 0.18);
  transform: translateX(100%);
  transition: transform 0.22s ease;
}

.drawer-layer.visible .drawer-backdrop {
  opacity: 1;
}

.drawer-layer.visible .drawer {
  transform: translateX(0);
}

.drawer-header {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-start;
  min-height: 76px;
  padding: 18px 24px;
  background: #fff;
  border-bottom: 1px solid #e5ebf2;
}

/* 标题绝对定位，才能相对整个抽屉居中（否则会被左侧返回按钮挤偏） */
.drawer-header h2 {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: calc(100% - 200px);
  margin: 0;
  color: #111827;
  font-size: 1.5rem;
  line-height: 1.5;
  text-align: center;
  transform: translate(-50%, -50%);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: #53627a;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.icon-button:hover {
  color: var(--primary);
  background: #eef6ff;
}

.icon-button svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* 抽屉左上角返回按钮：图标 + “返回”文字 */
.drawer-back-button {
  gap: 4px;
  width: auto;
  padding: 0 10px;
  font-size: 1rem;
}

.drawer-back-button svg {
  width: 18px;
  height: 18px;
}

.drawer-body {
  flex: 1 1 auto;
  padding: 0 24px 28px;
  overflow-y: auto;
}

.drawer-tabs {
  position: sticky;
  z-index: 2;
  top: 0;
  padding: 16px 0;
  background: #f8fbfe;
}

.drawer-tab {
  min-width: 84px;
  height: 42px;
  padding: 0 20px;
}

.drawer-list {
  display: grid;
  gap: 14px;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 24px 0 0;
  color: #526070;
  font-size: 0.875rem;
}

.pagination-info,
.pagination-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pagination-actions {
  gap: 10px;
}

.pagination button {
  min-height: 34px;
  color: #40516c;
  background: #fff;
  border: 1px solid #d8e3ed;
  border-radius: 5px;
  padding: 0 12px;
  cursor: pointer;
}

.pagination button:hover:not(:disabled) {
  color: var(--primary);
  border-color: #9dccfa;
}

.pagination button:disabled {
  color: #a9b2be;
  background: #f4f6f8;
  cursor: not-allowed;
}

.drawer-tutorial-card {
  grid-template-columns: 180px minmax(0, 1fr) 24px;
  min-height: 130px;
  padding: 14px 18px;
}

.drawer-tutorial-cover {
  width: 180px;
}

.drawer-tutorial-info {
  margin-left: 20px;
}

/* 抽屉卡片用 grid 定位箭头：第三列 24px = 箭头 18px + 图标与文字间距 margin-left 6px。
   两个值必须同步改；列宽若小于「箭头 + margin-left」，整个 margin box 会被顶出网格列，
   箭头会穿出卡片边框（这正是原来的 bug）。 */
.drawer-tutorial-card .card-arrow {
  margin-left: 6px;
}

.drawer-tutorial-info strong {
  font-size: 1.1875rem;
}

.drawer-tutorial-info span {
  margin-top: 10px;
  font-size: 1rem;
}

.drawer-qa-list {
  padding-bottom: 4px;
}

.drawer-qa-item {
  margin-bottom: 12px;
  overflow: hidden;
  background: #fff;
  border: 1px solid #dce6f0;
  border-radius: 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.drawer-qa-item.is-target {
  border-color: #409eff;
  box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.12);
}

.drawer-qa-item h3 {
  margin: 0;
  padding: 16px 18px 10px;
  color: #151b26;
  font-size: 1.125rem;
  line-height: 1.6;
}

.drawer-qa-item p {
  margin: 0;
  padding: 0 18px 16px;
  color: #526070;
  font-size: 1rem;
  line-height: 1.8;
  white-space: pre-wrap;
}

.tutorial-detail {
  max-width: 700px;
  padding: 24px 0;
}

.detail-cover {
  aspect-ratio: 16 / 6;
}

.detail-summary {
  margin: 20px 0 0;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.75;
}

.detail-divider {
  height: 1px;
  margin: 24px 0;
  background: #e2eaf2;
}

.tutorial-detail h3 {
  margin: 0 0 12px;
  color: var(--text-strong);
  font-size: 1.25rem;
}

.tutorial-detail > p:not(.detail-summary) {
  margin: 0;
  color: #44546a;
  font-size: 1rem;
  line-height: 1.9;
}

.detail-tip {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 28px;
  padding: 16px 18px;
  color: #526070;
  font-size: 0.9375rem;
  line-height: 1.7;
  background: #eef7ff;
  border-left: 4px solid var(--primary);
  border-radius: 4px;
}

.detail-tip strong {
  color: #1e5d9d;
}

@media (max-width: 1100px) {
  .tutorial-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .drawer {
    width: 62vw;
  }

  .drawer-tutorial-card {
    grid-template-columns: 140px minmax(0, 1fr) 24px;
  }

  .drawer-tutorial-cover {
    width: 140px;
  }
}

@media (max-width: 760px) {
  .page {
    padding: 12px;
  }

  .guide-content {
    min-height: calc(100vh - 24px);
    padding: 14px;
  }

  .category-tabs,
  .drawer-tabs {
    gap: 8px;
  }

  .category-tab {
    min-width: 76px;
    height: 38px;
    padding: 0 13px;
    font-size: 0.875rem;
  }

  .tutorial-grid,
  .qa-columns {
    grid-template-columns: 1fr;
  }

  .tutorial-card {
    grid-template-columns: 130px minmax(0, 1fr);
  }

  .drawer {
    width: 100%;
    min-width: 0;
  }

  .drawer-header {
    min-height: 66px;
    padding: 13px 16px;
  }

  .drawer-header h2 {
    font-size: 1.25rem;
  }

  .drawer-body {
    padding: 0 16px 24px;
  }

  .drawer-tab {
    min-width: 68px;
    height: 38px;
    padding: 0 12px;
  }

  .drawer-tutorial-card {
    grid-template-columns: 120px minmax(0, 1fr) 24px;
    min-height: 110px;
    padding: 12px;
  }

  .drawer-tutorial-cover {
    width: 120px;
  }

  .drawer-tutorial-info {
    margin-left: 14px;
  }
}

@media (max-width: 480px) {
  .section-heading h2 {
    font-size: 1.25rem;
  }

  .tutorial-card,
  .drawer-tutorial-card {
    grid-template-columns: 1fr;
  }

  .tutorial-cover,
  .drawer-tutorial-cover {
    width: 100%;
  }

  .tutorial-info,
  .drawer-tutorial-info {
    margin: 14px 0 2px;
  }

  .drawer-tutorial-card .card-arrow {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
