*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #FEFCF7;
  --text: #2C2416;
  --text-secondary: #6B5B3E;
  --gold: #D4AF37;
  --gold-dark: #A8852C;
  --gold-light: #F0E6C8;
  --gold-glow: rgba(212, 175, 55, 0.08);
  --card-bg: rgba(248, 244, 230, 0.5);
  --header-bg: rgba(255, 255, 255, 0.85);
  --border: rgba(212, 175, 55, 0.15);
  --shadow: rgba(212, 175, 55, 0.15);
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  position: relative;
}

a {
  color: var(--gold-dark);
  text-decoration: none;
  transition: color 0.2s;
}
a:hover { color: var(--gold); }

/* ==============================
   GOLDEN GLOW OVERLAY
   ============================== */
.golden-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  transition: background 0.1s ease;
}

/* ==============================
   LANGUAGE BAR
   ============================== */
.lang-bar {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 100;
  display: flex;
  gap: 2px;
  padding: 8px 16px;
  font-size: 14px;
}
.lang-bar a {
  display: inline-block;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0.6;
  transition: opacity 0.2s, transform 0.2s;
  font-size: 16px;
  line-height: 1;
}
.lang-bar a:hover {
  opacity: 1;
  transform: scale(1.15);
}

/* ==============================
   STICKY HEADER
   ============================== */
.sticky-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 90;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transform: translateY(-100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s;
  box-shadow: 0 2px 20px rgba(0,0,0,0.04);
}
.sticky-header.visible {
  transform: translateY(0);
}
.sticky-header nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
}
.nav-logo {
  font-size: 20px;
  font-weight: 800;
  color: var(--gold-dark);
  letter-spacing: 1px;
}
.nav-links {
  display: flex;
  gap: 4px;
}
.nav-links a {
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
}
.nav-links a:hover {
  background: var(--gold-light);
  color: var(--gold-dark);
}

/* ==============================
   HERO
   ============================== */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  padding: 120px 24px 80px;
}
.hero-content {
  position: relative;
  z-index: 1;
}
.hero h1 {
  font-size: clamp(48px, 10vw, 120px);
  font-weight: 800;
  color: var(--gold-dark);
  letter-spacing: 8px;
  text-shadow: 0 2px 40px var(--shadow);
  line-height: 1.1;
}
.hero-subtitle {
  font-size: clamp(18px, 3vw, 32px);
  color: var(--text-secondary);
  margin-top: 16px;
  font-weight: 300;
  letter-spacing: 4px;
}
.hero-greeting {
  font-size: clamp(16px, 2vw, 22px);
  color: var(--gold);
  margin-top: 24px;
  font-style: italic;
  font-weight: 400;
  min-height: 1.6em;
}

.scroll-arrow {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 36px;
  font-size: 28px;
  color: var(--gold);
  animation: floatArrow 2s ease-in-out infinite;
  cursor: pointer;
  line-height: 36px;
  text-align: center;
}
@keyframes floatArrow {
  0%, 100% { transform: translateX(-50%) translateY(0); opacity: 1; }
  50% { transform: translateX(-50%) translateY(10px); opacity: 0.5; }
}

/* ==============================
   PREVIEW SECTIONS
   ============================== */
.preview-section {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  position: relative;
  z-index: 1;
}
.preview-card {
  display: flex;
  align-items: center;
  gap: 60px;
  max-width: 1000px;
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 48px 56px;
  backdrop-filter: blur(4px);
  box-shadow: 0 8px 40px var(--shadow);
  transition: transform 0.4s, box-shadow 0.4s;
}
.preview-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 60px rgba(212, 175, 55, 0.2);
}

.preview-svg {
  flex-shrink: 0;
  width: 220px;
  height: 220px;
}
.preview-svg svg {
  width: 100%;
  height: 100%;
}

.preview-info { flex: 1; }
.preview-info h2 {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}
.preview-info .preview-desc {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.7;
}

.formulas {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}
.formula-text {
  display: inline-block;
  padding: 8px 20px;
  background: rgba(212, 175, 55, 0.08);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 20px;
  color: var(--gold-dark);
  font-weight: 600;
}
.formula-text .katex { font-size: 1.05em; }

.preview-cta {
  display: inline-block;
  padding: 12px 28px;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  border-radius: 12px;
  transition: transform 0.2s, box-shadow 0.2s;
  letter-spacing: 0.5px;
}
.preview-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(212, 175, 55, 0.35);
  color: #fff;
}

/* SVG animations */
.shape-draw {
  fill: none;
  stroke: var(--gold);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.shape-draw-fill {
  fill: var(--gold-light);
  fill-opacity: 0;
  transition: fill-opacity 0.8s ease 0.3s;
}
.preview-section.in-view .shape-draw-fill {
  fill-opacity: 1;
}
.shape-label {
  fill: var(--gold-dark);
  font-size: 14px;
  font-weight: 600;
}

/* ==============================
   FOOTER
   ============================== */
.footer {
  position: relative;
  z-index: 1;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  padding: 0;
}
.sincos-container {
  width: 100%;
  background: #faf8f0;
  border-bottom: 1px solid var(--border);
}
.sincos-container canvas {
  display: block;
  width: 100%;
  height: 180px;
}
.footer-info {
  text-align: center;
  padding: 40px 24px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 2;
}
.footer-info .copyright { font-weight: 600; color: var(--text); }
.footer-info .ai-note {
  color: var(--gold);
  font-style: italic;
  font-size: 13px;
}

/* ==============================
   NOSCRIPT
   ============================== */
noscript {
  display: block;
  padding: 16px;
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 8px;
  margin: 16px;
  text-align: center;
  color: #333;
}
noscript a { color: #0056b3; text-decoration: underline; }

/* ==============================
   RESPONSIVE
   ============================== */
@media (max-width: 768px) {
  .preview-card {
    flex-direction: column;
    padding: 32px 24px;
    gap: 24px;
  }
  .preview-svg {
    width: 160px;
    height: 160px;
  }
  .preview-info h2 { font-size: 26px; }
  .formula-text { font-size: 16px; padding: 6px 14px; }
  .nav-links { gap: 2px; }
  .nav-links a { padding: 4px 8px; font-size: 12px; }
  .lang-bar { font-size: 12px; padding: 6px 8px; gap: 1px; }
}

@media (max-width: 480px) {
  .preview-svg { width: 120px; height: 120px; }
  .preview-card { padding: 24px 16px; }
  .nav-links a { padding: 4px 6px; font-size: 11px; }
  .lang-bar a { font-size: 13px; }
}

/* ==============================
   ERROR PAGES
   ============================== */
.error-page {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  padding: 40px 24px;
}
.error-code {
  font-size: clamp(72px, 15vw, 140px);
  font-weight: 800;
  color: var(--gold);
  line-height: 1;
  margin-bottom: 8px;
}
.error-code span { color: var(--gold-dark); }
.error-title {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}
.error-desc {
  font-size: 16px;
  color: var(--text-secondary);
  max-width: 480px;
  margin-bottom: 32px;
  line-height: 1.7;
}
.error-link {
  display: inline-block;
  padding: 12px 28px;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: #fff;
  font-weight: 600;
  border-radius: 12px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.error-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(212, 175, 55, 0.35);
  color: #fff;
}

/* ==============================
   ARTICLE PAGES
   ============================== */
.article-page {
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 24px 80px;
  position: relative;
  z-index: 1;
}
.article-page h1 {
  font-size: 42px;
  font-weight: 800;
  color: var(--gold-dark);
  margin-bottom: 8px;
  letter-spacing: 1px;
}
.article-page .article-subtitle {
  color: var(--text-secondary);
  font-size: 18px;
  margin-bottom: 40px;
}
.article-page .article-section {
  margin-bottom: 40px;
}
.article-page .article-section h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--gold);
  display: inline-block;
}
.article-page .article-section p {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: 16px;
}
.article-page .formula-block {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 32px;
  margin-bottom: 20px;
}
.article-page .formula-block .formula-text {
  display: block;
  font-size: 24px;
  padding: 8px 0;
  background: none;
  border: none;
  text-align: center;
}
.article-page .formula-block .formula-label {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
  text-align: center;
}
.article-page .formula-block .formula-text .katex { font-size: 1.1em; }
.article-page .example-box {
  background: rgba(212, 175, 55, 0.06);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 32px;
  margin-bottom: 20px;
}
.article-page .example-box h3 {
  font-size: 18px;
  color: var(--gold-dark);
  margin-bottom: 12px;
}
.article-page .example-box p {
  color: var(--text);
  font-size: 15px;
  margin-bottom: 4px;
}
.article-page .article-svg-wrap {
  text-align: center;
  margin: 32px 0;
}
.article-page .article-svg-wrap svg {
  max-width: 280px;
  height: auto;
}
.article-page .back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 48px;
  padding: 12px 24px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-weight: 500;
  transition: background 0.2s, transform 0.2s;
}
.article-page .back-link:hover {
  background: var(--gold-light);
  transform: translateX(-4px);
}

@media (max-width: 768px) {
  .article-page { padding: 24px 16px 60px; }
  .article-page h1 { font-size: 30px; }
  .article-page .formula-block { padding: 16px 20px; }
  .article-page .formula-block .formula-text { font-size: 18px; }
}
