:root {
  --bg: #090d16;
  --bg-card: rgba(18, 24, 38, 0.7);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-faint: #94a3b8;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-glow: rgba(99, 102, 241, 0.22);
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --header-bg: rgba(9, 13, 22, 0.82);
  --title-color: #ffffff;
  --sub-bg: rgba(15, 23, 42, 0.5);
  --radial-1: rgba(99, 102, 241, 0.16);
  --btn-sec-bg: rgba(255, 255, 255, 0.05);
  --btn-sec-hover: rgba(255, 255, 255, 0.1);
  --trans-highlight: #93c5fd;
}

:root.light-theme {
  --bg: #f8fafc;
  --bg-card: rgba(255, 255, 255, 0.9);
  --border: rgba(15, 23, 42, 0.08);
  --border-hover: rgba(15, 23, 42, 0.16);
  --text: #0f172a;
  --text-muted: #475569;
  --text-faint: #64748b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-glow: rgba(79, 70, 229, 0.18);
  --header-bg: rgba(248, 250, 252, 0.85);
  --title-color: #0f172a;
  --sub-bg: rgba(241, 245, 249, 0.85);
  --radial-1: rgba(99, 102, 241, 0.08);
  --btn-sec-bg: rgba(15, 23, 42, 0.05);
  --btn-sec-hover: rgba(15, 23, 42, 0.1);
  --trans-highlight: #2563eb;
}

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

html {
  scroll-behavior: smooth;
}

main:focus {
  outline: none;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  background-image:
    radial-gradient(ellipse 65% 25% at 50% 0%, var(--radial-1), transparent 75%);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 clamp(20px, 3.5vw, 48px);
}

/* Navbar */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.24s ease, background-color 0.2s ease, border-color 0.2s ease;
}

/* Auto-retract on first page / hero screen */
header.nav-autohide {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

header.nav-autohide.is-visible,
header.nav-autohide.is-peeked,
header.nav-autohide:focus-within {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.navbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  width: 100%;
  padding: 0 clamp(20px, 3.5vw, 64px);
  box-sizing: border-box;
  gap: 20px;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.1rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-brand img {
  width: 30px;
  height: 30px;
  border-radius: 6px;
}

.nav-links {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 24px;
  list-style: none;
  margin: 0;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}

.nav-links a:hover {
  color: var(--text);
}

.navbar a:focus-visible,
.navbar button:focus-visible,
.navbar select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.language-picker select {
  max-width: 132px;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--btn-sec-bg);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.language-picker option {
  color: var(--text);
  background: var(--bg);
}

.btn-theme {
  background: var(--btn-sec-bg);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-theme:hover {
  background: var(--btn-sec-hover);
  border-color: var(--border-hover);
}

.btn-theme #themeMoon { display: block; }
.btn-theme #themeSun { display: none; }
:root.light-theme .btn-theme #themeMoon { display: none; }
:root.light-theme .btn-theme #themeSun { display: block; }

.btn-nav-guide {
  background: var(--primary);
  border: 1px solid var(--primary);
  color: #ffffff;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-nav-guide:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  transform: translateY(-1px);
}

/* Hero */
.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: calc(100svh - 40px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(96px, 12vh, 140px) 0 clamp(80px, 10vh, 120px);
  text-align: center;
}

.hero > .container { position: relative; z-index: 1; }

.hero-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: 980px;
  margin: 0 auto;
}

.hero-art {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(1000px, 115vw, 1920px);
  max-width: none;
  height: auto;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.hero-art__ribbon--one { animation: hero-drift-one 15s ease-in-out infinite; }
.hero-art__ribbon--two { animation: hero-drift-two 19s ease-in-out infinite; }
.hero-art__line--one { animation: hero-drift-one 17s ease-in-out infinite; }
.hero-art__line--two { animation: hero-drift-two 21s ease-in-out infinite; }
.hero-art__particles { animation: hero-sparkle 8s ease-in-out infinite; }
@keyframes hero-drift-one {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(10px, -12px); }
}
@keyframes hero-drift-two {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-10px, 12px); }
}
@keyframes hero-sparkle { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

.hero-title {
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "Songti TC", Georgia, serif;
  font-size: clamp(2.8rem, 5.8vw, 4.8rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.04em;
  margin: 0 auto;
  max-width: 960px;
  background: linear-gradient(135deg, #ffffff 15%, #ddd6fe 50%, #c4b5fd 75%, #93c5fd 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 45px rgba(167, 139, 250, 0.22);
}

:root.light-theme .hero-title {
  background: linear-gradient(135deg, #090d16 10%, #312e81 45%, #4f46e5 75%, #7c3aed 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
}

.hero-subtitle {
  font-size: clamp(1.1rem, 1.6vw, 1.32rem);
  color: var(--text-muted);
  max-width: 680px;
  margin: 28px auto 0;
  line-height: 1.75;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.hero-cta {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: 54px;
  margin-bottom: 0;
  scroll-margin-top: 110px;
}

.hero-cta-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.hero-cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 32px;
  color: #ffffff;
  background: var(--primary);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 12px;
  box-shadow: 0 6px 24px var(--primary-glow);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.15s ease;
  white-space: nowrap;
}

.hero-cta-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(79, 70, 229, 0.38);
}

.hero-cta-btn:active {
  transform: translateY(0);
}

.hero-cta-btn[hidden] {
  display: none !important;
}

/* Fallback mode when browser is unrecognized: show all 3 buttons */
.hero-cta-buttons.is-fallback .hero-cta-btn {
  background: var(--btn-sec-bg);
  color: var(--text);
  border: 1px solid var(--border-hover);
  box-shadow: none;
  padding: 12px 22px;
  font-size: 0.95rem;
}

.hero-cta-buttons.is-fallback .hero-cta-btn:hover {
  background: var(--btn-sec-hover);
  border-color: var(--primary);
  color: var(--title-color);
  transform: translateY(-1px);
}

.browser-icon { width: 20px; height: 20px; flex: none; }

.hero-cta-sub {
  margin-top: 18px;
  font-size: 0.88rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  text-align: center;
  line-height: 1.6;
}

.hero-cta-hint {
  color: var(--text-faint);
}

.hero-other-stores {
  color: var(--text-muted);
}

.hero-other-stores .store-link {
  color: var(--text);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--border-hover);
  text-underline-offset: 4px;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

.hero-other-stores .store-link:hover {
  color: var(--primary);
  text-decoration-color: var(--primary);
}

/* Section */
section {
  scroll-margin-top: 90px;
  padding: 128px 0;
}

/* Feature stories */
.feature-stories { display: grid; gap: 1px; }
.feature-story {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  align-items: center;
  gap: clamp(40px, 8vw, 112px);
  padding: 80px 0;
}
.feature-story[hidden] { display: none; }
.feature-story:first-child { padding-top: 24px; }
.feature-story-github .feature-story-copy,
.feature-story-edit .feature-story-copy { order: 2; }
.feature-story-github[hidden] ~ .feature-story-model .feature-story-copy,
.feature-story-github[hidden] ~ .feature-story-cache .feature-story-copy { order: 2; }
.feature-story-github[hidden] ~ .feature-story-edit .feature-story-copy { order: 0; }
.feature-story-copy { max-width: 480px; }
.feature-title {
  font-size: clamp(1.4rem, 2.3vw, 2rem);
  font-weight: 600;
  line-height: 1.3;
  color: var(--title-color);
  margin-bottom: 16px;
}
.feature-desc {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.8;
}
.feature-detail {
  margin-top: 28px;
  padding-left: 18px;
  border-left: 2px solid var(--primary);
}
.feature-detail-title { font-size: 1rem; margin-bottom: 6px; color: var(--title-color); }
.feature-icon-panel {
  position: relative;
  min-height: clamp(300px, 30vw, 360px);
  display: grid;
  place-items: center;
  padding: clamp(24px, 5vw, 56px);
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 50%, var(--primary-glow), transparent 58%),
    linear-gradient(145deg, var(--bg-card), var(--sub-bg));
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--trans-highlight);
}
.feature-icon-panel::before,
.feature-icon-panel::after {
  content: "";
  position: absolute;
  width: min(60%, 230px);
  aspect-ratio: 1;
  border-radius: 50%;
  pointer-events: none;
}
.feature-icon-panel::before { border: 1px solid var(--border); }
.feature-icon-panel::after {
  border: 1px solid transparent;
  border-top-color: var(--trans-highlight);
  opacity: 0.45;
  animation: panel-orbit 18s linear infinite;
}
.feature-icon {
  position: relative;
  z-index: 1;
  width: clamp(126px, 13vw, 156px);
  height: auto;
}
.icon-modes-lines { animation: icon-lines 5s ease-in-out infinite; }
.icon-github-badge { animation: icon-badge 5s ease-in-out infinite; }
.icon-model-core, .icon-model-nodes { transform-box: fill-box; transform-origin: center; }
.icon-model-core { animation: icon-pulse 4s ease-in-out infinite; }
.icon-model-nodes { animation: icon-nodes 4s ease-in-out infinite; }
.icon-edit-pencil { animation: icon-pencil 5s ease-in-out infinite; }
.icon-cache-hand { transform-origin: 69px 67px; animation: icon-clock 6s ease-in-out infinite; }
@keyframes panel-orbit { to { transform: rotate(360deg); } }
@keyframes icon-lines { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes icon-badge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes icon-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.35); } }
@keyframes icon-nodes { 0%, 100% { opacity: 0.7; } 50% { opacity: 1; } }
@keyframes icon-pencil { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-3px, 3px); } }
@keyframes icon-clock { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(30deg); } }
/* Footer */
footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  margin-top: 50px;
  color: var(--text-faint);
  font-size: 0.85rem;
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin-bottom: 12px;
}

.footer-links a {
  white-space: nowrap;
  color: var(--text-muted);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--text);
}

/* Shared interaction and content primitives. */
:where(a, button, select, summary):focus-visible {
  outline: 3px solid var(--trans-highlight);
  outline-offset: 4px;
}

.sr-only, .skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link:focus {
  position: fixed;
  top: 8px;
  left: 12px;
  z-index: 1000;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

@media (min-width: 641px) {
  #features { padding-top: 96px; }
  .feature-story { padding-bottom: 80px; }
  .feature-story + .feature-story { padding-top: 80px; }
}

@media (max-width: 900px) {
  .navbar { flex-wrap: wrap; gap: 10px 16px; }
  .nav-links { position: static; transform: none; order: 3; width: 100%; justify-content: center; flex-wrap: wrap; gap: 8px 24px; margin: 0; }
}

@media (max-width: 640px) {
  .navbar {
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 12px;
    padding: 8px 0;
  }
  .nav-brand { font-size: 1rem; }
  .nav-actions { gap: 8px; flex-wrap: wrap; justify-content: flex-end; max-width: 100%; flex-shrink: 1; }
  .btn-nav-guide { max-width: 100%; text-align: center; }
  .hero { min-height: calc(100svh - 60px); padding: 72px 0 44px; }
  .hero-art { width: 180%; max-width: none; }
  .hero-title { font-size: clamp(2.3rem, 8.5vw, 3rem); letter-spacing: 0.02em; overflow-wrap: anywhere; }
  .hero-subtitle { font-size: 1.05rem; margin-top: 20px; padding: 0 12px; }
  .hero-cta { margin-top: 40px; }
  .hero-cta-buttons { width: 100%; }
  .hero-cta-btn { font-size: 0.94rem; padding: 13px 22px; max-width: 100%; }
  .hero-cta-sub { font-size: 0.84rem; padding: 0 16px; margin-top: 14px; }
  .feature-story { grid-template-columns: minmax(0, 1fr); gap: 24px; padding: 48px 0; }
  .feature-story-github .feature-story-copy,
  .feature-story-edit .feature-story-copy,
  .feature-story-github[hidden] ~ .feature-story-model .feature-story-copy,
  .feature-story-github[hidden] ~ .feature-story-cache .feature-story-copy { order: 0; }
  .feature-icon-panel { min-height: 220px; }
  section { padding: 72px 0; scroll-margin-top: 24px; }
  footer { margin-top: 24px; padding: 24px 0; }
}

@media (max-width: 400px) {
  .hero { padding-top: 16px; padding-bottom: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
