:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f3f4f6;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border-color: #e5e7eb;
  --accent: #1677FF;
  --accent-hover: #0E5FD3;
  --glass-bg: rgba(255, 255, 255, 0.8);
  --card-bg: #ffffff;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.15);
  --gradient-text: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 50%, #ec4899 100%);
  --gradient-text-dark: linear-gradient(135deg, #60a5fa 0%, #a78bfa 50%, #f472b6 100%);
  --grid-color: rgba(22, 119, 255, 0.15);
  --scrollbar-thumb: #d1d5db;
  --scrollbar-track: #f3f4f6;
}

.dark {
  --bg-primary: #0a0a0a;
  --bg-secondary: #121212;
  --bg-tertiary: #1a1a1a;
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --border-color: #262626;
  --accent: #1677FF;
  --accent-hover: #36CFC9;
  --glass-bg: rgba(10, 10, 10, 0.8);
  --card-bg: #121212;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
  --gradient-text: linear-gradient(135deg, #60a5fa 0%, #a78bfa 50%, #f472b6 100%);
  --gradient-text-dark: linear-gradient(135deg, #60a5fa 0%, #a78bfa 50%, #f472b6 100%);
  --grid-color: rgba(91, 143, 249, 0.1);
  --scrollbar-thumb: #4b5563;
  --scrollbar-track: #1f2937;
}

* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 0;
}

.text-gradient {
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.dark .text-gradient {
  background: var(--gradient-text-dark);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.grid-pattern {
  background-image: radial-gradient(circle at 1px 1px, var(--grid-color) 1px, transparent 0);
  background-size: 40px 40px;
}

/* Slider captcha dark mode fix */
.dark .slider-captcha {
  background: #1f2937 !important;
  border-color: #374151 !important;
}
.dark .slider-track {
  background: linear-gradient(90deg,rgba(59,130,246,0.1),rgba(59,130,246,0.2)) !important;
}
.dark .slider-text {
  color: #6b7280 !important;
}

.dark .star-field::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 10% 15%, rgba(255,255,255,0.95), transparent),
    radial-gradient(1px 1px at 25% 40%, rgba(255,255,255,0.8), transparent),
    radial-gradient(1px 1px at 40% 10%, rgba(200,220,255,0.75), transparent),
    radial-gradient(1.5px 1.5px at 55% 65%, rgba(255,255,255,1), transparent),
    radial-gradient(1px 1px at 70% 30%, rgba(255,255,255,0.85), transparent),
    radial-gradient(1px 1px at 85% 55%, rgba(180,200,255,0.7), transparent),
    radial-gradient(1px 1px at 15% 75%, rgba(255,255,255,0.9), transparent),
    radial-gradient(2px 2px at 60% 80%, rgba(255,255,255,1), transparent),
    radial-gradient(1px 1px at 90% 88%, rgba(210,190,255,0.8), transparent),
    radial-gradient(1px 1px at 35% 55%, rgba(255,255,255,0.75), transparent);
  background-size: 250px 250px;
  pointer-events: none;
  z-index: 0;
  animation: starFloat1 12s ease-in-out infinite alternate, starTwinkle 4s ease-in-out infinite;
}

.dark .star-field::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 5% 50%, rgba(255,255,255,0.85), transparent),
    radial-gradient(1px 1px at 30% 25%, rgba(200,210,255,0.7), transparent),
    radial-gradient(1px 1px at 50% 70%, rgba(255,255,255,0.9), transparent),
    radial-gradient(1.5px 1.5px at 75% 45%, rgba(255,255,255,0.95), transparent),
    radial-gradient(1px 1px at 95% 20%, rgba(190,220,255,0.75), transparent),
    radial-gradient(1px 1px at 20% 90%, rgba(255,255,255,0.8), transparent),
    radial-gradient(2px 2px at 80% 15%, rgba(255,255,255,1), transparent);
  background-size: 300px 300px;
  pointer-events: none;
  z-index: 0;
  animation: starFloat2 15s ease-in-out infinite alternate, starTwinkle2 5s ease-in-out infinite;
}

.dark .star-field .star-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(3px 3px at 18% 22%, rgba(255,255,255,1), transparent),
    radial-gradient(2.5px 2.5px at 62% 48%, rgba(200,220,255,1), transparent),
    radial-gradient(2px 2px at 88% 68%, rgba(255,255,255,0.95), transparent),
    radial-gradient(2px 2px at 42% 85%, rgba(180,210,255,0.95), transparent);
  background-size: 400px 400px;
  animation: starGlow 5s ease-in-out infinite alternate;
}

.dark .star-field .star-layer-1 {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(1px 1px at 12% 32%, rgba(255,255,255,0.9), transparent),
    radial-gradient(1.5px 1.5px at 48% 18%, rgba(200,220,255,0.95), transparent),
    radial-gradient(1px 1px at 72% 62%, rgba(255,255,255,0.85), transparent),
    radial-gradient(1px 1px at 88% 38%, rgba(255,255,255,0.75), transparent);
  background-size: 350px 350px;
  animation: starFloat1 10s ease-in-out infinite alternate-reverse, starTwinkle 6s ease-in-out infinite;
}

.dark .star-field .star-layer-2 {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(2px 2px at 25% 70%, rgba(255,255,255,1), transparent),
    radial-gradient(1.5px 1.5px at 55% 40%, rgba(180,210,255,0.9), transparent),
    radial-gradient(1px 1px at 82% 82%, rgba(255,255,255,0.85), transparent);
  background-size: 280px 280px;
  animation: starFloat2 18s ease-in-out infinite alternate-reverse, starTwinkle2 7s ease-in-out infinite;
}

@keyframes starTwinkle {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

@keyframes starTwinkle2 {
  0%, 100% { opacity: 0.5; }
  30% { opacity: 0.2; }
  80% { opacity: 0.9; }
}

@keyframes starFloat1 {
  0% { transform: translate(0, 0); }
  25% { transform: translate(8px, -12px); }
  50% { transform: translate(-5px, 6px); }
  75% { transform: translate(12px, 4px); }
  100% { transform: translate(-3px, -8px); }
}

@keyframes starFloat2 {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-10px, 8px); }
  40% { transform: translate(6px, -10px); }
  60% { transform: translate(-8px, -4px); }
  80% { transform: translate(4px, 12px); }
  100% { transform: translate(10px, -6px); }
}

@keyframes starGlow {
  0%, 100% { opacity: 0.4; filter: blur(0px) brightness(1); }
  50% { opacity: 1; filter: blur(2px) brightness(1.3); }
}

.glass-nav {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
}

.dropdown-menu {
  min-width: max-content;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
}

.has-dropdown:hover .dropdown-menu,
.has-dropdown.nav-open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  white-space: nowrap;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.dropdown-item:hover {
  color: var(--accent);
  background: var(--bg-secondary);
}

.btn-primary {
  background: var(--accent);
  color: white;
  font-weight: 700;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  cursor: pointer;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 10px 25px -5px rgba(22, 119, 255, 0.4);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  font-weight: 700;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
}

.btn-secondary:hover {
  border-color: var(--accent) !important;
  color: var(--accent);
}

.card-hover {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
}

.feature-icon-wrap {
  background: rgba(22, 119, 255, 0.1);
  transition: transform 0.3s ease;
}

.dark .feature-icon-wrap {
  background: rgba(22, 119, 255, 0.15);
}

.feature-icon-wrap:hover {
  transform: scale(1.08);
}

.back-to-top {
  position: fixed;
  right: 24px;
  bottom: 140px;
  width: 48px;
  height: 48px;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.3s ease;
  z-index: 100;
  border: none;
  box-shadow: 0 10px 25px -5px rgba(22, 119, 255, 0.4);
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 15px 30px -5px rgba(22, 119, 255, 0.5);
}

.hero-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-20px); }
}

@keyframes pulse-slow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in {
  animation: fade-in-up 0.6s ease-out forwards;
}

.animate-pulse-slow {
  animation: pulse-slow 4s ease-in-out infinite;
}

.sidebar-toc {
  position: fixed;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 40;
}

.toc-dot {
  width: 12px;
  height: 12px;
  background: var(--border-color);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.toc-dot::after {
  content: '';
  position: absolute;
  inset: -4px;
  border: 2px solid var(--accent);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.toc-dot.active {
  background: var(--accent);
}

.toc-dot.active::after {
  opacity: 1;
}

.toc-tooltip {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--card-bg);
  color: var(--text-primary);
  padding: 4px 10px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  border: 1px solid var(--border-color);
  white-space: nowrap;
}

.toc-dot:hover .toc-tooltip {
  opacity: 1;
  visibility: visible;
  left: 28px;
}

[class*="rounded-"] {
  border-radius: 0 !important;
}

/* ===== Responsive: hide sidebar TOC on tablet/mobile ===== */
@media (max-width: 1023px) {
  .sidebar-toc {
    display: none;
  }
}

/* ===== Mobile navigation dropdown enhancements ===== */
/* Ensure mobile menu can scroll if it overflows */
#mobile-menu {
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Mobile details/summary dropdown styling */
#mobile-menu details > summary {
  list-style: none;
}
#mobile-menu details > summary::-webkit-details-marker {
  display: none;
}
#mobile-menu details > summary {
  outline: none;
}

/* Desktop hover dropdown: keep hover behavior, but also allow click on touch */
@media (hover: none) {
  /* On touch devices, hover-only dropdowns don't work well.
     We rely on the mobile menu (lg:hidden) for small screens,
     so this only affects tablets >=1024px without hover. */
  .has-dropdown:hover .dropdown-menu,
  .has-dropdown:focus-within .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
  .has-dropdown:focus-within .dropdown-menu {
    /* keep visible when interacting */
  }
}

/* ===== Global responsive content scaling ===== */

/* Large desktops: cap content width and add comfortable padding */
@media (min-width: 1536px) {
  .max-w-7xl {
    max-width: 1280px;
  }
}

/* Tablets (<=1023px): tighten oversized spacing */
@media (max-width: 1023px) {
  section[class*="py-24"] {
    padding-top: 4rem;
    padding-bottom: 4rem;
  }
}

/* Mobile (<=767px): scale down hero, headings, spacing, and ensure full-width content */
@media (max-width: 767px) {
  /* Hero section padding */
  section[id="hero"] {
    padding-top: 6rem;
    padding-bottom: 4rem;
  }

  /* Scale down oversized hero headings */
  h1.text-5xl {
    font-size: 2.25rem;
    line-height: 1.15;
  }
  h2.text-3xl {
    font-size: 1.875rem;
    line-height: 1.2;
  }

  /* Ensure buttons are full-width and tappable */
  .btn-primary,
  .btn-secondary {
    width: 100%;
    min-height: 48px;
  }

  /* Cards: reduce padding on mobile */
  .card-hover {
    padding: 1.25rem;
  }

  /* Pricing: remove the scale transform that causes horizontal overflow */
  .transform.scale-105 {
    transform: none !important;
  }

  /* Footer: stack columns cleanly */
  footer .flex-wrap {
    flex-direction: column;
    align-items: flex-start;
  }

  /* Back-to-top: position to avoid overlapping content */
  .back-to-top {
    right: 16px;
    bottom: 16px;
    width: 44px;
    height: 44px;
  }

  /* Code blocks: enable horizontal scroll without breaking layout */
  pre {
    font-size: 0.8rem;
    -webkit-overflow-scrolling: touch;
  }

  /* Prevent any element from causing horizontal scroll */
  img,
  svg,
  video,
  pre,
  table {
    max-width: 100%;
  }

  /* Nav height adjustments for smaller screens */
  nav .h-16,
  nav .h-20 {
    height: 56px;
  }

  /* Ensure the "开始使用" button in nav is hidden on small screens (already md:hidden, but enforce) */
}

/* Very small phones (<=380px): further reduce font sizes */
@media (max-width: 380px) {
  h1.text-5xl,
  h1[class*="text-5xl"] {
    font-size: 1.9rem;
  }
  .text-xl {
    font-size: 1rem;
  }
  .text-2xl {
    font-size: 1.15rem;
  }
}

/* ===== Prevent horizontal overflow globally ===== */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

/* Ensure grid items don't overflow */
.grid {
  min-width: 0;
}
.grid > * {
  min-width: 0;
}

/* Flex items should shrink properly */
.flex {
  min-width: 0;
}

/* Long words/URLs should break */
p,
li,
a,
span {
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Pre/code blocks: scroll instead of overflow */
pre {
  overflow-x: auto;
  max-width: 100%;
}

/* ===== Footer layout ===== */
.footer-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  width: 100%;
  align-items: flex-start;
}
.footer-left {
  flex: 0 0 auto;
  min-width: 220px;
}
.footer-brand {
  margin-bottom: 0;
}
.footer-menus {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  flex: 1;
}
.footer-menus h4 {
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}
.footer-menus ul {
  font-size: 0.8rem;
}
.footer-menus ul li {
  margin-bottom: 0.375rem;
}
.footer-right {
  flex: 0 0 auto;
}

/* ===== Footer QR codes (desktop: right side, mobile: bottom) ===== */
.footer-qr {
  display: flex;
  gap: 1rem;
  justify-content: flex-start;
  align-items: flex-start;
}
.footer-qr-desktop {
  display: flex;
}
.footer-qr-mobile {
  display: none;
}
.footer-qr-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
}
.footer-qr-img {
  width: 96px;
  height: 96px;
  background: #fff;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}
.footer-qr-img svg {
  width: 48px;
  height: 48px;
}
.footer-qr-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: center;
}

/* ===== Mobile bottom action bar (call + WeChat) ===== */
.mobile-action-bar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  background: var(--card-bg);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
}
.mobile-action-bar-inner {
  display: flex;
}
.mobile-action-bar a {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.875rem 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s ease;
}
.mobile-action-bar a.call-btn {
  background: var(--accent);
  color: #fff;
}
.mobile-action-bar a.call-btn:hover {
  background: var(--accent-hover);
}
.mobile-action-bar a.kf-btn {
  background: #07c160;
  color: #fff;
}
.mobile-action-bar a.kf-btn:hover {
  background: #06ad56;
}

/* ===== Show mobile action bar only on mobile ===== */
@media (max-width: 767px) {
  .mobile-action-bar {
    display: block;
  }
  /* Add bottom padding so content isn't hidden behind the bar */
  body {
    padding-bottom: 56px;
  }
  /* Back-to-top sits above the action bar, middle-lower side */
  .back-to-top {
    right: 16px;
    bottom: 72px;
    width: 44px;
    height: 44px;
  }
  /* Footer: stack left, middle, right; QR codes move to bottom */
  .footer-layout {
    flex-direction: column;
  }
  .footer-left {
    flex: 1 1 100%;
    min-width: 0;
  }
  .footer-menus {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    width: 100%;
  }
  .footer-menus h4 {
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
  }
  .footer-menus ul {
    font-size: 0.7rem;
  }
  .footer-menus ul li {
    margin-bottom: 0.25rem;
  }
  .footer-right {
    display: none;
  }
  /* QR codes: mobile shown at bottom, desktop hidden */
  .footer-qr-desktop {
    display: none;
  }
  .footer-qr-mobile {
    display: flex;
    justify-content: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
  }
  .footer-qr-img {
    width: 80px;
    height: 80px;
  }
  .footer-qr-img svg {
    width: 40px;
    height: 40px;
  }
}

/* ===== GitHub cat icon link in nav ===== */
.nav-github-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  border-radius: 0;
  transition: background 0.2s ease, color 0.2s ease;
  color: var(--text-secondary);
}
.nav-github-link:hover {
  background: var(--bg-secondary);
  color: var(--accent);
}
