:root {
  color-scheme: light;
  --text: #213547;
  --muted: #5f6368;
  --line: #e2e8f0;
  --soft: #f6f6f7;
  --accent: #3451b2;
  --accent-hover: #3a5ccc;
  --bg: #ffffff;
  --topbar: rgba(255, 255, 255, 0.96);
  --code-bg: #f6f8fa;
  --code-text: #3451b2;
  --code-border: #d8e3f8;
  --block-code-bg: #1e1e2e;
  --block-code-text: #cdd6f4;
  --active-bg: #eef0fd;
}

[data-theme="dark"] {
  color-scheme: dark;
  --text: #dce4ef;
  --muted: #9ca3af;
  --line: #2e3748;
  --soft: #1a1e2e;
  --accent: #7c9af3;
  --accent-hover: #9ab1f7;
  --bg: #1b1b1f;
  --topbar: rgba(27, 27, 31, 0.96);
  --code-bg: #1e2336;
  --code-text: #9ab1f7;
  --code-border: #334155;
  --block-code-bg: #0d0f17;
  --block-code-text: #dce4ef;
  --active-bg: #1e2a4a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.7;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* 正文内链接带下划线，与 VitePress 一致 */
.article a,
.home-content a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.article a:hover,
.home-content a:hover {
  color: var(--accent-hover);
}

.resource-download-button,
.resource-download-button:hover {
  color: #fff !important;
  text-decoration: none !important;
}

.zzswitch-promo {
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--active-bg) 72%, transparent), transparent 58%),
    var(--soft);
  box-shadow: 0 18px 42px rgba(22, 33, 62, 0.10);
  color: var(--text);
}

.zzswitch-promo__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.zzswitch-promo__badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
}

.zzswitch-promo__title,
.zzswitch-promo__desc {
  margin: 0;
}

.zzswitch-promo__title {
  font-weight: 800;
  line-height: 1.35;
}

.zzswitch-promo__desc {
  color: var(--muted);
  line-height: 1.65;
}

.zzswitch-promo__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.zzswitch-promo__primary {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--bg);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.article .zzswitch-promo__primary,
.article .zzswitch-promo__primary:hover,
.zzswitch-promo__primary:hover {
  color: var(--bg);
  text-decoration: none;
}

.zzswitch-promo__primary:hover {
  background: var(--accent-hover);
}

.zzswitch-promo--banner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin: 0 0 28px;
  padding: 18px;
  border-radius: 10px;
}

.zzswitch-promo--banner .zzswitch-promo__title {
  font-size: 19px;
}

.zzswitch-promo--banner .zzswitch-promo__desc {
  margin-top: 6px;
  font-size: 14px;
}

.zzswitch-promo--aside {
  margin: 0 0 20px;
  padding: 14px;
  border-radius: 10px;
}

.zzswitch-promo--aside .zzswitch-promo__title {
  font-size: 14px;
}

.zzswitch-promo--aside .zzswitch-promo__desc {
  margin-top: 6px;
  font-size: 13px;
}

.zzswitch-promo--aside .zzswitch-promo__actions {
  margin-top: 12px;
}

.zzswitch-promo--aside .zzswitch-promo__primary {
  width: 100%;
  min-height: 34px;
  font-size: 13px;
}

.zzswitch-promo--mobile {
  display: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 56px;
  border-bottom: 1px solid var(--line);
  background: var(--topbar);
  backdrop-filter: saturate(180%) blur(5px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1440px;
  height: 100%;
  margin: 0 auto;
  padding: 0 32px 0 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  align-self: stretch;
  width: 272px;
  flex-shrink: 0;
  padding-left: 32px;
}

.topbar-center {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  padding: 0 16px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.brand {
  color: var(--text);
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 16px;
  overflow: hidden;
}

.topnav a {
  padding: 2px 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.topnav a:hover,
.topnav a[aria-current="page"] {
  color: var(--accent);
  background: transparent;
  text-decoration: none;
}

.menu-button,
.search-button {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.menu-button {
  display: none;
  width: 36px;
  padding: 0;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
}

.menu-icon,
.menu-icon::before,
.menu-icon::after {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  transition: transform 0.2s;
}

.menu-icon {
  position: relative;
}

.menu-icon::before,
.menu-icon::after {
  content: "";
  position: absolute;
  left: 0;
}

.menu-icon::before { top: -5px; }
.menu-icon::after  { top:  5px; }

.search-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 150px;
  color: var(--muted);
  text-align: left;
}

.search-button::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  flex-shrink: 0;
}

.search-button::after {
  content: "";
  width: 6px;
  height: 2px;
  margin-left: -17px;
  margin-right: 2px;
  background: var(--muted);
  transform: rotate(45deg) translate(7px, 7px);
}

.search-button span {
  margin-right: auto;
  margin-left: 8px;
}

.search-button kbd {
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  background: var(--soft);
  font: inherit;
  font-size: 12px;
}

.topbar-divider {
  width: 1px;
  height: 20px;
  background: var(--line);
  flex-shrink: 0;
}

/* Theme toggle: show sun in light mode, moon in dark mode */
.theme-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}

.theme-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-button .icon-moon { display: none; }
.theme-button .icon-sun  { display: block; }
[data-theme="dark"] .theme-button .icon-moon { display: block; }
[data-theme="dark"] .theme-button .icon-sun  { display: none; }

.shell {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr) 220px;
  gap: 32px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 32px 56px;
}

.sidebar,
.outline {
  position: sticky;
  top: 72px;
  align-self: start;
  max-height: calc(100vh - 84px);
  overflow: auto;
  font-size: 14px;
}

.sidebar {
  border-right: 1px solid var(--line);
  padding-right: 20px;
}

.sidebar-item {
  margin: 4px 0;
}

.sidebar-item span {
  display: block;
  margin: 14px 0 6px;
  color: var(--text);
  font-weight: 700;
}

.sidebar-item a {
  display: block;
  padding: 3px 8px;
  border-radius: 6px;
  color: var(--muted);
}

.sidebar-item a[aria-current="page"] {
  color: var(--accent);
  background: var(--active-bg);
  font-weight: 650;
}

.sidebar ul {
  list-style: none;
  margin: 0 0 0 10px;
  padding: 0;
}

.sidebar-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 3px 8px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
}

.sidebar-group-toggle:hover {
  color: var(--accent);
}

.sidebar-caret {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-left: 4px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235f6368' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  transition: transform 0.2s;
}

.sidebar-group.collapsed .sidebar-caret {
  transform: rotate(-90deg);
}

.sidebar-group.collapsed > ul {
  display: none;
}

.content {
  min-width: 0;
  max-width: 840px;
}

.article h1 {
  margin-top: 0;
  font-size: 34px;
  line-height: 1.2;
}

.article h2,
.article h3,
.article h4 {
  margin-top: 32px;
  line-height: 1.3;
}

.article img {
  max-width: 100%;
}

.article table {
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
}

.article th,
.article td {
  padding: 8px 10px;
  border: 1px solid var(--line);
}

.article :not(pre) > code {
  padding: 2px 5px;
  border: 1px solid var(--code-border);
  border-radius: 5px;
  background: var(--code-bg);
  color: var(--code-text);
  font-size: 0.92em;
  font-weight: 650;
}

.code-block {
  overflow-x: auto;
  padding: 16px;
  border-radius: 8px;
  background: var(--block-code-bg);
  color: var(--block-code-text);
}

.shiki {
  overflow-x: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg) !important;
}

[data-theme="dark"] .shiki {
  color: var(--shiki-dark, var(--block-code-text)) !important;
  background: var(--shiki-dark-bg, var(--block-code-bg)) !important;
}

[data-theme="dark"] .shiki span {
  color: var(--shiki-dark, var(--block-code-text)) !important;
  background: transparent !important;
}

.shiki code {
  background: transparent;
}

.heading-anchor {
  margin-left: 8px;
  color: var(--muted);
  opacity: 0;
}

h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor {
  opacity: 1;
}

.outline nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.outline strong {
  margin-bottom: 8px;
}

.outline a {
  color: var(--muted);
}

.outline .level-3 {
  padding-left: 12px;
}

.outline .level-4 {
  padding-left: 24px;
}

.prev-next {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.prev-next a {
  display: flex;
  flex: 0 1 260px;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
}

.prev-next a:last-child {
  align-items: flex-end;
  text-align: right;
}

.prev-next a span {
  color: var(--muted);
  font-size: 12px;
}

.error-page {
  max-width: 680px;
  margin: 12vh auto;
  padding: 0 24px;
}

@media (max-width: 767px) {
  .zzswitch-promo--banner {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .zzswitch-promo--mobile {
    position: fixed;
    right: 12px;
    bottom: 12px;
    left: 12px;
    z-index: 40;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border-radius: 12px;
  }

  .zzswitch-promo--mobile .zzswitch-promo__meta,
  .zzswitch-promo--mobile .zzswitch-promo__desc {
    display: none;
  }

  .zzswitch-promo--mobile .zzswitch-promo__title {
    font-size: 14px;
  }

  .zzswitch-promo--mobile .zzswitch-promo__primary {
    min-height: 34px;
    padding: 0 12px;
    font-size: 13px;
  }

  body:has(.zzswitch-promo--mobile) {
    padding-bottom: 74px;
  }
}

@media (max-width: 980px) {
  .menu-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .topbar-inner {
    padding: 0 16px;
  }

  .topbar-left {
    width: auto;
    padding-left: 0;
    background: transparent;
  }

  .topbar-center {
    flex: none;
    padding-left: 12px;
  }

  .topnav {
    display: none;
  }

  .search-button {
    width: 44px;
    padding: 0;
    justify-content: center;
  }

  .search-button span,
  .search-button kbd,
  .search-button::after {
    display: none;
  }

  .topbar-divider {
    display: none;
  }

  .shell {
    grid-template-columns: 1fr;
    padding: 20px;
  }

  .sidebar {
    display: none;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0 0 16px;
  }

  .sidebar.is-open {
    display: block;
  }

  .outline {
    display: none;
  }
}

/* ── Home page ── */
.home-main {
  max-width: 1152px;
  margin: 0 auto;
}

/* Hero — 左对齐，与 VitePress 默认主题一致 */
.home-hero {
  padding: 80px 48px 64px;
}

.home-hero-name {
  width: fit-content;
  max-width: 392px;
  letter-spacing: -0.4px;
  line-height: 40px;
  font-size: 32px;
  font-weight: 700;
  white-space: pre-wrap;
  color: var(--accent);
}

.home-hero-text {
  width: fit-content;
  max-width: 392px;
  letter-spacing: -0.4px;
  line-height: 40px;
  font-size: 32px;
  font-weight: 700;
  white-space: pre-wrap;
  color: var(--text);
}

.home-hero-tagline {
  padding-top: 8px;
  max-width: 392px;
  line-height: 28px;
  font-size: 18px;
  font-weight: 500;
  white-space: pre-wrap;
  color: var(--muted);
}

.home-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin: -6px;
  padding-top: 24px;
}

.hero-action {
  display: inline-block;
  margin: 6px;
  border: 1px solid transparent;
  border-radius: 20px;
  padding: 0 20px;
  line-height: 38px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  transition: color 0.25s, border-color 0.25s, background-color 0.25s;
}

.hero-action-brand {
  color: #fff;
  background-color: #5672cd;
}

.hero-action-brand:hover {
  background-color: #3a5ccc;
  text-decoration: none;
}

.hero-action-alt {
  color: var(--text);
  background-color: var(--soft);
}

.hero-action-alt:hover {
  background-color: var(--line);
  text-decoration: none;
}

/* Features — 所有卡片同一行，整体可点击 */
.home-features {
  padding: 0 48px 64px;
  display: flex;
  flex-wrap: nowrap;
  gap: 16px;
  overflow-x: auto;
}

.home-feature,
.home-feature-link {
  flex: 1 1 0;
  min-width: 160px;
  border: 1px solid var(--soft);
  border-radius: 12px;
  background-color: var(--soft);
  padding: 24px;
  display: flex;
  flex-direction: column;
  transition: border-color 0.25s, background-color 0.25s;
  text-decoration: none;
  color: inherit;
}

.home-feature-link:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.feature-icon {
  font-size: 24px;
  margin-bottom: 12px;
}

.feature-title {
  margin: 0 0 8px;
  line-height: 24px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.feature-details {
  margin: 0;
  flex-grow: 1;
  line-height: 24px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

.feature-link-text {
  margin: 12px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}

.home-content {
  padding: 0 48px 64px;
}

/* home-content 内的表格也要有样式 */
.home-content table {
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 16px 0;
}

.home-content th,
.home-content td {
  padding: 8px 10px;
  border: 1px solid var(--line);
}

.home-content th {
  background: var(--soft);
  font-weight: 600;
}

.home-content tr:nth-child(even) td {
  background: color-mix(in srgb, var(--soft) 40%, transparent);
}

@media (max-width: 960px) {
  .home-hero {
    padding: 48px 32px 40px;
  }

  .home-features {
    flex-wrap: wrap;
    padding: 0 32px 40px;
  }

  .home-feature,
  .home-feature-link {
    flex: 1 1 calc(50% - 8px);
  }

  .home-content {
    padding: 0 32px 40px;
  }
}

@media (max-width: 640px) {
  .home-hero {
    padding: 40px 24px 32px;
  }

  .home-hero-name,
  .home-hero-text {
    font-size: 28px;
    line-height: 36px;
  }

  .home-hero-tagline {
    font-size: 16px;
    line-height: 26px;
  }

  .home-features {
    padding: 0 24px 32px;
  }

  .home-feature,
  .home-feature-link {
    flex: 1 1 100%;
  }

  .home-content {
    padding: 0 24px 32px;
  }
}

/* ── Footer ── */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 16px 24px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

.footer-inner p {
  margin: 4px 0;
}

.footer-inner a {
  color: var(--accent);
  text-decoration: none;
}

.footer-inner a:hover {
  text-decoration: underline;
}

.footer-inner .sep {
  color: var(--muted);
  opacity: 0.5;
}
