/* SafeW Global Styles */
:root {
  /* Colors */
  --color-dark-bg: #17203F;
  --color-paper: #FCFCFD;
  --color-text: #151823;
  --color-brand: #1441EB;
  --color-accent: #6EEDBD;
  
  /* Tokens */
  --radius-card: 8px;
  --radius-btn: 6px;
  --card-border: 1px solid rgba(21, 24, 35, 0.16);
  --card-shadow: none;
  --section-y: clamp(3.5rem, 7vw, 6rem);
  --gap: clamp(1rem, 2vw, 1.75rem);
  --content-max: 1120px;
  
  /* Typography */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  --text-base: 16px;
  --line-height: 1.65;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--line-height);
  color: var(--color-text);
  background-color: var(--color-paper);
  overflow-x: hidden;
}

/* Layout Containers */
.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}

section {
  padding-top: var(--section-y);
  padding-bottom: var(--section-y);
  position: relative;
}

/* Dark Section Overrides */
section.dark-section {
  background-color: var(--color-dark-bg);
  color: var(--color-paper);
}

section.dark-section h2,
section.dark-section h3,
section.dark-section p,
section.dark-section li {
  color: var(--color-paper);
}

section.dark-section .hl {
  color: var(--color-accent);
}

section.dark-section .section-label {
  color: var(--color-accent);
}

section.dark-section a:not(.btn) {
  color: var(--color-accent);
}

/* Paper Card inside Dark Section */
.paper-card {
  background-color: var(--color-paper);
  color: var(--color-text);
  border-radius: var(--radius-card);
  padding: var(--gap);
  border: var(--card-border);
}

.paper-card h3,
.paper-card p,
.paper-card li {
  color: var(--color-text);
}

.paper-card .hl {
  color: var(--color-brand);
}

/* Typography */
h1, h2, h3, h4 {
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.4rem, 6vw, 4.5rem);
  margin-bottom: var(--gap);
}

h2 {
  font-size: clamp(1.8rem, 3.5vw, 2.8rem);
  margin-bottom: var(--gap);
}

h3 {
  font-size: clamp(1.4rem, 2.5vw, 1.8rem);
  margin-bottom: 1rem;
}

p {
  margin-bottom: 1.5rem;
  max-width: 38em;
}

a {
  color: var(--color-brand);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

a:hover {
  opacity: 0.8;
}

/* Section Labels */
.section-label {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-brand);
  margin-bottom: 1rem;
  position: relative;
  padding-left: 1.5rem;
}

.section-label::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 2px;
  background-color: currentColor;
}

/* Highlighted Text */
.hl {
  color: var(--color-brand);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 52px;
  padding: 0 24px;
  border-radius: var(--radius-btn);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
  text-decoration: none;
  border: none;
}

.btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-dark-bg);
}

.btn-primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
}

.btn-secondary {
  background-color: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-text);
}

section.dark-section .btn-secondary {
  color: var(--color-paper);
  border-color: var(--color-paper);
}

.btn-secondary:hover {
  background-color: rgba(0,0,0,0.05);
}

section.dark-section .btn-secondary:hover {
  background-color: rgba(255,255,255,0.1);
}

/* Header & Nav */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(252, 252, 253, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(0,0,0,0.05);
  padding: 16px 0;
}

section.dark-section ~ .site-header {
  background-color: rgba(23, 32, 63, 0.95);
  border-bottom-color: rgba(255,255,255,0.1);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo img {
  height: 32px;
  width: auto;
  vertical-align: middle;
}

.nav-links {
  display: flex;
  gap: 24px;
  list-style: none;
}

.nav-links a {
  color: var(--color-text);
  font-weight: 500;
  font-size: 0.95rem;
}

.nav-links a:hover {
  color: var(--color-brand);
}

.nav-links a[aria-current="page"] {
  color: var(--color-brand);
  font-weight: 700;
}

/* Footer */
.site-footer {
  background-color: var(--color-dark-bg);
  color: var(--color-paper);
  padding: 64px 0 32px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 48px;
  margin-bottom: 48px;
}

.footer-col h4 {
  color: var(--color-accent);
  margin-bottom: 16px;
  font-size: 1rem;
}

.footer-col ul {
  list-style: none;
}

.footer-col li {
  margin-bottom: 12px;
}

.footer-col a {
  color: rgba(252, 252, 253, 0.7);
  font-size: 0.9rem;
}

.footer-col a:hover {
  color: var(--color-accent);
}

.copyright {
  text-align: center;
  color: rgba(252, 252, 253, 0.4);
  font-size: 0.85rem;
  padding-top: 32px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

/* Components: Cards & Tables */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

.card {
  background: var(--color-paper);
  border: var(--card-border);
  border-radius: var(--radius-card);
  padding: 24px;
  transition: transform 0.2s ease;
}

.card:hover {
  transform: translateY(-4px);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 0.95rem;
}

.data-table th,
.data-table td {
  padding: 16px;
  border-bottom: 1px solid rgba(0,0,0,0.1);
  text-align: left;
}

.data-table th {
  font-weight: 700;
  color: var(--color-text);
  width: 40%;
}

section.dark-section .data-table th,
section.dark-section .data-table td {
  border-bottom-color: rgba(255,255,255,0.1);
  color: var(--color-paper);
}

/* FAQ Details/Summary */
details.faq-item {
  border-bottom: 1px solid rgba(0,0,0,0.1);
  margin-bottom: 16px;
  padding-bottom: 16px;
}

section.dark-section details.faq-item {
  border-bottom-color: rgba(255,255,255,0.1);
}

summary {
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  position: relative;
  padding-right: 24px;
  font-size: 1.1rem;
}

summary::-webkit-details-marker {
  display: none;
}

summary::after {
  content: "+";
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.2rem;
  color: var(--color-brand);
}

details[open] summary::after {
  content: "-";
  color: var(--color-accent);
}

.faq-answer {
  margin-top: 12px;
  color: var(--color-text);
  line-height: 1.7;
}

section.dark-section .faq-answer {
  color: rgba(252, 252, 253, 0.8);
}

/* SVG Animations */
svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.star-dot {
  fill: var(--color-accent);
  animation: star-flicker 4s infinite alternate ease-in-out;
}

.star-dot:nth-child(odd) {
  animation-delay: 2s;
  animation-duration: 5s;
}

.sync-line {
  stroke: var(--color-accent);
  stroke-width: 2;
  fill: none;
  stroke-dasharray: 10 5;
  animation: line-flow 2s linear infinite;
}

@keyframes star-flicker {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

@keyframes line-flow {
  to { stroke-dashoffset: -30; }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .nav-links {
    display: none; /* Simplified for mobile, usually would be a hamburger menu */
  }
  
  .header-inner {
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
  }
  
  .btn {
    width: auto;
    flex-shrink: 0;
  }
  
  .card-grid {
    grid-template-columns: 1fr;
  }

  section.dark-section .container > div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  #workflow .container > div[style*="justify-content: space-between"] {
    flex-direction: column;
  }

  #ui-demo .paper-card > div[style*="grid-template-columns: 240px 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Fix horizontal overflow on small screens */
  body {
    overflow-x: hidden;
  }
  
  .container {
    max-width: 100%;
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* Tab Navigation for Features (CSS Only) */
.feature-tabs {
  display: flex;
  gap: 16px;
  margin-bottom: 32px;
  border-bottom: 2px solid rgba(0,0,0,0.1);
  overflow-x: auto;
  padding-bottom: 4px;
}

.feature-tab-link {
  padding: 12px 24px;
  font-weight: 700;
  color: var(--color-text);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
}

.feature-tab-link:hover {
  color: var(--color-brand);
}

.feature-content {
  display: none;
}

.feature-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Fallback for no JS: show all features in a list if needed, 
   but here we rely on the user clicking tabs or JS adding 'active' class.
   To strictly meet "visible without JS", we could use radio buttons.
   However, for simplicity and modern UX, we'll use a small script in HTML
   or rely on the fact that content is structurally there.
   Let's implement pure CSS radio tabs for full compliance. */

.radio-tabs input[type="radio"] {
  display: none;
}

.radio-tabs label {
  display: inline-block;
  padding: 12px 24px;
  font-weight: 700;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: var(--color-text);
}

.radio-tabs input[type="radio"]:checked + label {
  color: var(--color-brand);
  border-bottom-color: var(--color-brand);
}

.tab-panel {
  display: none;
}

#tab-feature-1:checked ~ .tab-content-1,
#tab-feature-2:checked ~ .tab-content-2,
#tab-feature-3:checked ~ .tab-content-3 {
  display: block;
  animation: fadeIn 0.3s ease;
}

/* If JS is disabled, we can't easily toggle without radio hack structure.
   The radio hack above works without JS! Perfect. */

/* 兜底：裁掉横向溢出 */
body > * {
  overflow-x: clip;
}
