/* =========================================
   Design Tokens & Variables
   ========================================= */
:root {
  --color-bg-base: #161618;
  --color-bg-surface: #232326;
  --color-bg-elevated: #323236;
  --color-border-subtle: #404045;
  --color-text-primary: #ededed;
  --color-text-secondary: #9a9a9f;
  --color-text-muted: #6b6b70;
  
  --color-brand: #25d366;
  --color-brand-dark: #17733e;
  --color-brand-dim: rgba(37, 211, 102, 0.15);
  
  --color-earth: #b48a5c;
  --color-earth-light: #d4a574;
  --color-earth-dim: rgba(180, 138, 92, 0.12);
  
  --font-heading: 'Inter', system-ui, -apple-system, 'Helvetica Neue', sans-serif;
  --font-body: system-ui, -apple-system, 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', Roboto, sans-serif;
  
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 2rem;
  --space-lg: 4rem;
  --space-xl: 8rem;
  --space-xxl: 12rem;
  
  --radius-sm: 0.375rem;
  --radius-md: 0.75rem;
  --radius-lg: 1.25rem;
  --radius-full: 9999px;
  
  --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.5);
  
  --transition-base: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =========================================
   Reset & Base
   ========================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
  background-color: var(--color-bg-base);
  color: var(--color-text-primary);
  line-height: 1.6;
  font-size: 16px;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition-base);
}

ul, ol {
  list-style: none;
}

/* =========================================
   Typography & Text Handling (Fix Overflow)
   ========================================= */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  text-wrap: balance;
  overflow-wrap: break-word;
}

h1 {
  font-size: clamp(2.25rem, 5vw + 1rem, 4.5rem);
  font-weight: 800;
  margin-bottom: var(--space-sm);
}

h2 {
  font-size: clamp(1.75rem, 3vw + 0.5rem, 3rem);
  margin-bottom: var(--space-md);
}

h3 {
  font-size: clamp(1.25rem, 2vw + 0.5rem, 1.5rem);
  margin-bottom: var(--space-sm);
}

p {
  color: var(--color-text-secondary);
  margin-bottom: var(--space-sm);
  max-width: 65ch;
  overflow-wrap: break-word;
}

.text-center { text-align: center; }
.mx-auto { margin-left: auto; margin-right: auto; }

/* 针对特定元素的防溢出修复 */
code, pre {
  font-family: monospace, monospace;
  white-space: pre-wrap;
  word-break: break-all;
}

td, th {
  overflow-wrap: break-word;
  word-break: break-word;
}

/* =========================================
   Layout & Grid
   ========================================= */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-md);
  position: relative;
}

.section {
  padding: var(--space-lg) 0;
  position: relative;
  overflow: hidden;
}

.grid-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  align-items: center;
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-md);
}

.full-width-banner {
  width: 100%;
  background: linear-gradient(135deg, var(--color-bg-surface) 0%, var(--color-bg-base) 100%);
  border-top: 1px solid var(--color-border-subtle);
  border-bottom: 1px solid var(--color-border-subtle);
  padding: var(--space-lg) 0;
  overflow: hidden;
}

/* =========================================
   Header & Navigation
   ========================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(22, 22, 24, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border-subtle);
  padding: var(--space-sm) 0;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-text-primary);
  flex-shrink: 0;
}

.brand img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.nav-list {
  display: flex;
  gap: var(--space-md);
}

.nav-link {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  padding: 0.5rem 0;
  position: relative;
  flex-shrink: 0;
}

.nav-link:hover, .nav-link[aria-current="page"] {
  color: var(--color-text-primary);
}

.nav-link[aria-current="page"]::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--color-brand);
  border-radius: 1px;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--color-text-primary);
  cursor: pointer;
  padding: var(--space-xs);
  flex-shrink: 0;
}

/* =========================================
   Buttons
   ========================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 1.75rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-base);
  text-decoration: none;
  flex-shrink: 0;
  white-space: nowrap;
}

.btn-primary {
  background: var(--color-brand);
  color: #000;
  border-color: var(--color-brand);
}

.btn-primary:hover {
  background: var(--color-brand-dark);
  border-color: var(--color-brand-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.25);
}

.btn-outline {
  background: transparent;
  color: var(--color-text-primary);
  border-color: var(--color-border-subtle);
}

.btn-outline:hover {
  border-color: var(--color-text-primary);
  background: rgba(255,255,255,0.05);
}

.btn-group {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

/* =========================================
   Cards & Components
   ========================================= */
.card {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base);
  overflow: hidden;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: var(--color-earth);
}

.card-icon {
  width: 48px;
  height: 48px;
  background: var(--color-earth-dim);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-sm);
  color: var(--color-earth-light);
  flex-shrink: 0;
}

.card-icon svg {
  width: 24px;
  height: 24px;
  stroke-width: 1.5;
}

.tag {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: var(--color-brand-dim);
  color: var(--color-brand);
  margin-bottom: var(--space-xs);
}

/* =========================================
   Table
   ========================================= */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  table-layout: auto;
}

th, td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border-subtle);
  vertical-align: top;
}

th {
  background: var(--color-bg-elevated);
  font-weight: 600;
  color: var(--color-text-primary);
  white-space: nowrap;
}

td {
  color: var(--color-text-secondary);
  word-break: normal;
  hyphens: auto;
}

tr:last-child td {
  border-bottom: none;
}

/* =========================================
   FAQ
   ========================================= */
.faq-item {
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
  overflow: hidden;
  background: var(--color-bg-surface);
}

.faq-item summary {
  padding: 1.25rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--color-text-primary);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background var(--transition-base);
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: '+';
  font-size: 1.25rem;
  color: var(--color-text-muted);
  transition: transform var(--transition-base);
}

.faq-item[open] summary::after {
  transform: rotate(45deg);
}

.faq-item summary:hover {
  background: var(--color-bg-elevated);
}

.faq-item p {
  padding: 0 1.25rem 1.25rem;
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--color-text-secondary);
  word-break: break-word;
}

/* =========================================
   News & Related Links
   ========================================= */
.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-md);
}

.news-card {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  transition: transform var(--transition-base);
  overflow: hidden;
}

.news-card:hover {
  transform: translateY(-3px);
  border-color: var(--color-earth);
}

.news-date {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.news-title {
  font-weight: 600;
  font-size: 1.1rem;
  line-height: 1.4;
  overflow-wrap: break-word;
}

.news-excerpt {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  flex-grow: 1;
  word-break: break-word;
}

.related-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-sm);
}

.related-link {
  padding: var(--space-sm);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  transition: all var(--transition-base);
  display: flex;
  flex-direction: column;
}

.related-link:hover {
  background: var(--color-bg-elevated);
  border-color: var(--color-text-muted);
}

.link-text {
  font-weight: 500;
  display: block;
  margin-bottom: 0.25rem;
  overflow-wrap: break-word;
}

.link-desc {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  overflow-wrap: break-word;
}

/* =========================================
   Footer
   ========================================= */
.site-footer {
  border-top: 1px solid var(--color-border-subtle);
  padding: var(--space-lg) 0 var(--space-md);
  background: var(--color-bg-surface);
  margin-top: var(--space-xl);
  overflow: hidden;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.footer-col h4 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
}

.footer-col ul li {
  margin-bottom: 0.5rem;
}

.footer-col a {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
}

.footer-col a:hover {
  color: var(--color-brand);
}

.footer-bottom {
  border-top: 1px solid var(--color-border-subtle);
  padding-top: var(--space-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* =========================================
   SVG Animations
   ========================================= */
.svg-anim-container {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  aspect-ratio: 16/9;
  position: relative;
}

svg {
  width: 100%;
  height: 100%;
}

.draw-path {
  pathLength: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  animation: draw-and-breathe 7s ease-in-out infinite;
}

.draw-path-alt {
  pathLength: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  animation: draw-and-breathe-alt 8s ease-in-out infinite 1s;
}

@keyframes draw-and-breathe {
  0%, 8% { stroke-dashoffset: 1; }
  15%, 85% { stroke-dashoffset: 0; }
  92%, 100% { stroke-dashoffset: 1; }
}

@keyframes draw-and-breathe-alt {
  0%, 10% { stroke-dashoffset: 1; }
  20%, 80% { stroke-dashoffset: 0; }
  90%, 100% { stroke-dashoffset: 1; }
}

@keyframes float-pulse {
  0%, 100% { transform: translateY(0); opacity: 0.6; }
  50% { transform: translateY(-8px); opacity: 1; }
}

.float-element {
  animation: float-pulse 4s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .draw-path, .draw-path-alt, .float-element {
    animation: none;
  }
}

/* =========================================
   Responsive Adjustments
   ========================================= */
@media (max-width: 768px) {
  .grid-split {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
  
  .nav-list {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--color-bg-surface);
    flex-direction: column;
    padding: var(--space-md);
    border-bottom: 1px solid var(--color-border-subtle);
    z-index: 101;
  }
  
  .nav-list.is-open {
    display: flex;
  }
  
  .mobile-menu-btn {
    display: block;
  }
  
  .section {
    padding: var(--space-md) 0;
  }
  
  /* 针对小屏幕的场景卡片布局优化，防止横向溢出 */
  .scenario-scroll {
    display: grid;
    gap: var(--space-sm);
    overflow-x: visible;
    grid-template-columns: 1fr;
  }
  
  .scenario-card {
    min-width: unset;
    flex-shrink: 0;
  }
}

/* Focus styles for accessibility */
:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}

.btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 3px;
}
