:root {
  --bg: #0a0e14;
  --bg-alt: #0d131c;
  --panel: #111927;
  --line: #1e2a3a;
  --text: #dbe4ee;
  --muted: #8fa1b5;
  --cyan: #38e1ff;
  --cyan-dim: #1b6d80;
  --orange: #ff9d45;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "Microsoft YaHei", sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--cyan-dim); }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0.8rem 1.5rem;
  background: rgba(10, 14, 20, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav-brand {
  display: flex; align-items: center; gap: 0.55rem;
  color: var(--cyan); text-decoration: none;
  font-family: var(--mono); font-weight: 600; font-size: 1rem;
}
.nav-mark { width: 22px; height: 22px; }
.nav-links { display: flex; gap: 1.3rem; margin-left: auto; }
.nav-links a {
  color: var(--muted); text-decoration: none; font-size: 0.9rem;
  transition: color 0.15s;
}
.nav-links a:hover { color: var(--cyan); }
.nav-actions { display: flex; align-items: center; gap: 0.7rem; }
.lang-toggle {
  background: none; border: 1px solid var(--line); border-radius: 6px;
  color: var(--muted); font-family: var(--mono); font-size: 0.8rem;
  padding: 0.3rem 0.7rem; cursor: pointer; transition: all 0.15s;
}
.lang-toggle:hover { color: var(--cyan); border-color: var(--cyan-dim); }

/* ---------- buttons ---------- */
.btn {
  display: inline-block; padding: 0.65rem 1.4rem; border-radius: 8px;
  font-size: 0.95rem; font-weight: 600; text-decoration: none;
  transition: all 0.15s;
}
.btn-sm { padding: 0.35rem 0.9rem; font-size: 0.85rem; }
.btn-primary {
  background: var(--cyan); color: #04202a;
  box-shadow: 0 0 24px rgba(56, 225, 255, 0.25);
}
.btn-primary:hover { box-shadow: 0 0 34px rgba(56, 225, 255, 0.45); }
.btn-ghost { border: 1px solid var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--cyan-dim); color: var(--cyan); }

/* ---------- hero ---------- */
.hero {
  position: relative; overflow: hidden;
  padding: 5.5rem 1.5rem 4.5rem;
  background:
    radial-gradient(ellipse 60% 50% at 70% 20%, rgba(56, 225, 255, 0.07), transparent),
    radial-gradient(ellipse 50% 40% at 20% 80%, rgba(255, 157, 69, 0.05), transparent),
    var(--bg);
}
.hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(56, 225, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 225, 255, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, black, transparent);
}
.hero-inner {
  position: relative; max-width: 1160px; margin: 0 auto;
  display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 3.5rem; align-items: center;
}
.hero-kicker {
  font-family: var(--mono); font-size: 0.85rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--orange); margin-bottom: 1.1rem;
}
.hero h1 {
  font-size: clamp(2.2rem, 4.5vw, 3.4rem); line-height: 1.12;
  font-weight: 800; letter-spacing: -0.02em; margin-bottom: 1.2rem;
}
.hero h1 .accent { color: var(--cyan); }
.hero-sub { color: var(--muted); font-size: 1.08rem; max-width: 34rem; margin-bottom: 1.8rem; }
.hero-ctas { display: flex; gap: 0.9rem; flex-wrap: wrap; margin-bottom: 1.6rem; }
.hero-badges {
  display: flex; gap: 0.6rem; flex-wrap: wrap; list-style: none;
}
.hero-badges li {
  font-family: var(--mono); font-size: 0.75rem; color: var(--muted);
  border: 1px solid var(--line); border-radius: 99px; padding: 0.2rem 0.75rem;
}

/* ---------- terminal ---------- */
.hero-terminal {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  font-family: var(--mono); font-size: 0.78rem;
}
.term-bar {
  display: flex; align-items: center; gap: 0.45rem;
  padding: 0.55rem 0.9rem; background: #0c121c; border-bottom: 1px solid var(--line);
}
.term-bar-alt { border-top: 1px solid var(--line); }
.term-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.term-dot:first-child { background: #ff5f57; }
.term-dot:nth-child(2) { background: #febc2e; }
.term-dot:nth-child(3) { background: #28c840; }
.term-title { margin-left: 0.5rem; color: var(--muted); font-size: 0.75rem; }
.term-body { padding: 0.9rem 1.1rem; color: #a9c1d6; white-space: pre-wrap; }
.term-body em { color: var(--orange); font-style: normal; }
.term-body strong { color: var(--cyan); font-weight: 600; }

/* ---------- sections ---------- */
.section { padding: 5rem 1.5rem; max-width: 1160px; margin: 0 auto; }
.section-alt {
  max-width: none; background: var(--bg-alt); border-block: 1px solid var(--line);
}
.section-alt > * { max-width: 1160px; margin-left: auto; margin-right: auto; }
.section-kicker {
  font-family: var(--mono); font-size: 0.8rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--cyan); margin-bottom: 0.7rem;
}
.section h2 {
  font-size: clamp(1.6rem, 3vw, 2.3rem); font-weight: 800;
  letter-spacing: -0.02em; margin-bottom: 0.8rem;
}
.section-sub { color: var(--muted); max-width: 46rem; margin-bottom: 2.6rem; }

/* ---------- loop ---------- */
.loop-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 1rem;
  list-style: none; counter-reset: loop;
}
.loop-card {
  position: relative; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 1.4rem 1.2rem;
  transition: border-color 0.2s, transform 0.2s;
}
.loop-card:hover { border-color: var(--cyan-dim); transform: translateY(-3px); }
.loop-num {
  font-family: var(--mono); font-size: 0.75rem; color: var(--orange);
  display: block; margin-bottom: 0.6rem;
}
.loop-card h3 { font-size: 1.05rem; margin-bottom: 0.5rem; }
.loop-card p { font-size: 0.87rem; color: var(--muted); }

/* ---------- pillars ---------- */
.pillar-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.2rem;
}
.pillar {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 1.6rem;
}
.pillar h3 {
  display: flex; align-items: center; gap: 0.7rem;
  font-size: 1.15rem; margin-bottom: 1rem;
}
.pillar-tag {
  font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.1em;
  color: var(--cyan); border: 1px solid var(--cyan-dim); border-radius: 5px;
  padding: 0.15rem 0.5rem;
}
.pillar ul { list-style: none; }
.pillar li {
  position: relative; padding-left: 1.3rem; margin-bottom: 0.55rem;
  color: var(--muted); font-size: 0.92rem;
}
.pillar li::before {
  content: "▸"; position: absolute; left: 0; color: var(--cyan);
}

/* ---------- dual-speed ---------- */
.ds-problem {
  display: flex; align-items: baseline; gap: 1rem;
  border: 1px solid var(--line); border-left: 4px solid var(--orange);
  background: var(--panel); border-radius: 10px;
  padding: 1rem 1.3rem; margin-bottom: 2rem;
  color: var(--muted); font-size: 0.95rem;
}
.ds-problem-num {
  font-family: var(--mono); font-size: 1.5rem; font-weight: 700;
  color: var(--orange); white-space: nowrap;
}
.dual {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 1.4rem; align-items: stretch;
}
.dual-col {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 1.8rem;
}
.dual-slow { border-top: 3px solid var(--orange); }
.dual-fast { border-top: 3px solid var(--cyan); }
.dual-col h3 { font-size: 1.2rem; margin-bottom: 0.3rem; }
.dual-role {
  font-family: var(--mono); font-size: 0.78rem; color: var(--muted);
  margin-bottom: 1.1rem;
}
.dual-col ul { list-style: none; }
.dual-col li {
  position: relative; padding-left: 1.3rem; margin-bottom: 0.6rem;
  color: var(--muted); font-size: 0.92rem;
}
.dual-slow li::before { content: "◆"; position: absolute; left: 0; color: var(--orange); font-size: 0.7rem; top: 0.25rem; }
.dual-fast li::before { content: "◆"; position: absolute; left: 0; color: var(--cyan); font-size: 0.7rem; top: 0.25rem; }
.dual-seam {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.5rem; min-width: 110px;
}
.dual-seam-label {
  font-family: var(--mono); font-size: 0.72rem; color: var(--text);
  border: 1px solid var(--line); border-radius: 99px; padding: 0.25rem 0.8rem;
  background: var(--bg);
}
.dual-seam-line {
  width: 1px; flex: 1; min-height: 40px;
  background: linear-gradient(var(--orange), var(--cyan));
}
.dual-seam-sub {
  font-family: var(--mono); font-size: 0.65rem; color: var(--muted);
  writing-mode: vertical-rl;
}

/* ---------- rules ---------- */
.rules-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem;
}
.rule-card {
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 1.6rem; transition: border-color 0.2s;
}
.rule-card:hover { border-color: var(--cyan-dim); }
.rule-card-featured { border-color: var(--cyan-dim); background: linear-gradient(160deg, rgba(56, 225, 255, 0.05), var(--panel) 45%); }
.rule-card header {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 0.8rem; margin-bottom: 0.9rem;
}
.rule-card h3 { font-size: 1.15rem; }
.rule-tag {
  font-family: var(--mono); font-size: 0.68rem; color: var(--orange);
  white-space: nowrap;
}
.rule-card p { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.2rem; flex: 1; }
.rule-caps {
  display: flex; flex-wrap: wrap; gap: 0.45rem; list-style: none;
}
.rule-caps li {
  font-family: var(--mono); font-size: 0.72rem; color: var(--cyan);
  background: rgba(56, 225, 255, 0.07); border: 1px solid rgba(56, 225, 255, 0.18);
  border-radius: 6px; padding: 0.2rem 0.55rem;
}

/* ---------- quick start ---------- */
.qs-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem;
  margin-bottom: 2rem;
}
.qs-step { display: flex; flex-direction: column; min-width: 0; }
.qs-step h3 { font-size: 1rem; margin-bottom: 0.8rem; color: var(--text); min-height: 2.4em; }
.qs-step pre {
  flex: 1;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 1rem 1.1rem; overflow-x: auto;
  font-family: var(--mono); font-size: 0.78rem; color: #a9c1d6; line-height: 1.7;
}
.warning {
  display: flex; gap: 0.8rem; align-items: baseline; flex-wrap: wrap;
  border: 1px solid rgba(255, 157, 69, 0.35); border-left: 4px solid var(--orange);
  background: rgba(255, 157, 69, 0.06); border-radius: 10px;
  padding: 1.1rem 1.3rem; font-size: 0.9rem;
}
.warning strong { color: var(--orange); white-space: nowrap; }
.warning span { color: var(--muted); }

/* ---------- footer ---------- */
.footer { border-top: 1px solid var(--line); padding: 2rem 1.5rem; }
.footer-inner {
  max-width: 1160px; margin: 0 auto;
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; flex-wrap: wrap;
  font-size: 0.85rem; color: var(--muted);
}
.footer nav { display: flex; gap: 1.3rem; }
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--cyan); }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .hero-inner { grid-template-columns: 1fr; gap: 2.5rem; }
  .loop-grid { grid-template-columns: repeat(2, 1fr); }
  .pillar-grid, .rules-grid, .qs-grid { grid-template-columns: 1fr; }
  .dual { grid-template-columns: 1fr; }
  .dual-seam { flex-direction: row; min-width: 0; padding: 0.4rem 0; }
  .dual-seam-line { width: auto; height: 1px; flex: 1; min-height: 0;
    background: linear-gradient(90deg, var(--orange), var(--cyan)); }
  .dual-seam-sub { writing-mode: horizontal-tb; }
  .nav-links { display: none; }
}

@media (max-width: 560px) {
  .loop-grid { grid-template-columns: 1fr; }
  .hero { padding-top: 3.5rem; }
}

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