/* 核心主题变量 */
:root {
  --font-sans: system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"PingFang SC","Microsoft YaHei",sans-serif;
  --font-mono: "JetBrains Mono","Fira Code",monospace;
  --color-bg: #060a1a;
  --color-bg-alt: #0d132b;
  --color-surface: rgba(255,255,255,0.04);
  --color-border: rgba(255,255,255,0.12);
  --color-text: #d6deff;
  --color-text-dim: #8ca0d0;
  --color-accent: #5d7bff;
  --color-accent-glow: 170 55% 55%;
  --color-danger: #ff4d6d;
  --grad-accent: linear-gradient(120deg,#6d8dff,#8b5dff 50%,#ff4dc2);
  --shadow-neon: 0 0 4px #6d8dff, 0 0 12px #6d8dff55;
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-full: 1000px;
  --trans-fast: .18s cubic-bezier(.4,.2,.2,1);
  --trans-slow: .6s cubic-bezier(.22,.11,.11,.99);
  --blur-backdrop: 14px;
  --noise-opacity: 0.045;
  --font-size-fluid: clamp(1rem, 0.9rem + 0.4vw, 1.15rem);
}
:root[data-theme="light"] {
  --color-bg: #f5f7ff;
  --color-bg-alt: #e6ecfa;
  --color-surface: rgba(0,0,40,0.05);
  --color-border: rgba(0,0,40,0.12);
  --color-text: #1e2540;
  --color-text-dim: #4a5775;
  --color-accent: #324adf;
  --shadow-neon: 0 0 0 transparent;
  --noise-opacity: 0.02;
}
:root[data-neon="on"] {
  --shadow-neon: 0 0 6px #7fa2ff,0 0 14px #7fa2ff66,0 0 28px #7fa2ff33;
  --color-accent: #8aa4ff;
}

* { box-sizing: border-box; }
html,body { height:100%; }
body {
  margin:0;
  font-family: var(--font-sans);
  font-size: var(--font-size-fluid);
  line-height:1.6;
  background: radial-gradient(circle at 25% 15%, #101a33 0%, var(--color-bg) 60%) fixed;
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x:hidden;
}

.visually-hidden {
  position:absolute; width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);border:0;
}

canvas#starfield {
  position:fixed; inset:0;
  width:100%; height:100%; display:block;
  z-index:-3;
}

.scanlines {
  pointer-events:none;
  position:fixed; inset:0;
  background:
    repeating-linear-gradient(to bottom,rgba(255,255,255,0.06),rgba(255,255,255,0.06) 1px,transparent 1px,transparent 3px);
  mix-blend-mode: overlay;
  opacity:.07;
  z-index:-1;
  animation: scanScroll 9s linear infinite;
}
@keyframes scanScroll {
  0% { background-position-y:0; }
  100% { background-position-y:300px; }
}
.noise {
  position:fixed; inset:0;
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.35'/></svg>");
  mix-blend-mode: soft-light;
  opacity: var(--noise-opacity);
  pointer-events:none;
  z-index:-2;
  animation: noiseShift 4s steps(8,end) infinite;
}
@keyframes noiseShift {
  to { transform: translate3d(0,0,0); }
}

.site-header {
  position:sticky; top:0;
  backdrop-filter: blur(var(--blur-backdrop)) saturate(140%);
  background: linear-gradient(180deg,rgba(10,15,35,0.85),rgba(10,15,35,0.35));
  padding: .75rem clamp(.9rem,2vw,2.4rem);
  display:flex; align-items:center; gap:1rem;
  border-bottom:1px solid var(--color-border);
  z-index:50;
}
.logo-wrap { flex:0 0 auto; }
.logo {
  display:flex; align-items:center; gap:.55rem;
  text-decoration:none;
  font-weight:600;
  font-size:1.05rem;
  letter-spacing:.5px;
  background: var(--grad-accent);
  -webkit-background-clip:text;
  color:transparent;
  filter: drop-shadow(0 2px 4px #000);
}
.logo-icon { font-size:1.15rem; }
.nav-toggle {
  background:none; border:1px solid var(--color-border);
  padding:.45rem; border-radius:var(--radius-sm);
  cursor:pointer; display:none; flex-direction:column; gap:4px;
  transition: var(--trans-fast);
}
.nav-toggle .bar {
  width:22px; height:2px; background:var(--color-text);
  border-radius:2px;
}
.nav {
  flex:1;
}
.nav ul {
  margin:0; padding:0; list-style:none;
  display:flex; gap:1.6rem;
}
.nav a {
  color:var(--color-text-dim);
  text-decoration:none;
  position:relative;
  font-weight:500;
  transition: var(--trans-fast);
}
.nav a:focus-visible, .nav a:hover {
  color:var(--color-text);
}
.nav a::after {
  content:"";
  position:absolute; left:0; bottom:-6px;
  height:2px; width:0;
  background:var(--grad-accent);
  transition: var(--trans-fast);
  border-radius:2px;
}
.nav a:hover::after, .nav a:focus-visible::after {
  width:100%;
}

.header-actions {
  display:flex; align-items:center; gap:.6rem;
}
.theme-toggle, .neon-toggle {
  background:var(--color-surface);
  color:var(--color-text);
  width:40px; height:40px;
  display:grid; place-items:center;
  font-size:1rem;
  border:1px solid var(--color-border);
  border-radius:var(--radius-sm);
  cursor:pointer;
  position:relative;
  transition: var(--trans-fast);
  box-shadow: var(--shadow-neon);
}
.theme-toggle:hover, .neon-toggle:hover {
  background:var(--color-accent);
  color:#fff;
  box-shadow:0 4px 14px -4px #0008, var(--shadow-neon);
}

.search {
  position:relative;
  display:flex; align-items:center;
}
.search input {
  background:var(--color-surface);
  border:1px solid var(--color-border);
  color:var(--color-text);
  padding:.6rem .9rem .6rem 2.1rem;
  border-radius: var(--radius-full);
  font: inherit;
  width:165px;
  transition: var(--trans-fast);
}
.search input:focus {
  outline:1px solid var(--color-accent);
  width:220px;
}
.search-icon {
  position:absolute;
  left:.75rem;
  color:var(--color-text-dim);
  font-size:.85rem;
  pointer-events:none;
}

.hero {
  position:relative;
  min-height: min(85vh, 780px);
  display:grid;
  place-items:center;
  text-align:center;
  padding: clamp(2rem, 8vh, 7rem) 1.5rem 4rem;
  overflow:hidden;
}
.hero-inner {
  max-width: 920px;
  z-index:2;
}
.hero-overlay {
  position:absolute; inset:0;
  background:
    radial-gradient(circle at 50% 40%,rgba(90,115,255,0.25),transparent 55%),
    linear-gradient(180deg,rgba(6,10,26,0) 0%,rgba(6,10,26,0.6) 70%,rgba(6,10,26,0.9) 100%);
  pointer-events:none;
  z-index:1;
}
.hero h1 {
  font-size: clamp(2.3rem, 1.7rem + 4vw, 4.5rem);
  margin:0 0 1.1rem;
  letter-spacing: 1px;
  position:relative;
  line-height:1.05;
  font-weight:700;
  animation: titleFloat 8s ease-in-out infinite;
}
@keyframes titleFloat {
  0%,100% { transform:translateY(0); }
  50% { transform:translateY(-8px); }
}

/* Glitch effect */
.glitch {
  --glitch-color: #8aa4ff;
  text-shadow:
    0 0 1px #fff,
    1px 0 6px var(--glitch-color),
    -2px 0 4px #ff4dc2aa;
  position:relative;
}
.glitch::before,
.glitch::after {
  content:attr(data-text);
  position:absolute; inset:0;
  mix-blend-mode: lighten;
  animation: glitch 3s infinite;
  opacity:.6;
}
.glitch::before {
  transform: translate(1px,0);
  color:#ff9ecf;
  clip-path: polygon(0 0,100% 0,100% 45%,0 45%);
}
.glitch::after {
  transform: translate(-1px,0);
  color:#6dacff;
  clip-path: polygon(0 55%,100% 55%,100% 100%,0 100%);
  animation-delay: 1.5s;
}
@keyframes glitch {
  0%,6%,12%,18%,22%,100% { transform: translate(0,0); }
  3% { transform:translate(-3px,-1px); }
  9% { transform:translate(3px,2px); }
  15% { transform:translate(-2px,1px); }
  20% { transform:translate(2px,-2px); }
}

.typewriter {
  min-height:2.2rem;
  font-family: var(--font-mono);
  font-size: clamp(1.05rem, 0.95rem + .5vw, 1.4rem);
  background: linear-gradient(90deg,#fff,#8fa9ff 45%,#ff9ed9);
  -webkit-background-clip:text;
  color:transparent;
  letter-spacing:.5px;
  margin:.2rem auto 1.85rem;
  position:relative;
}
.typewriter::after {
  content:"";
  display:inline-block;
  width:2px;
  height:1.1em;
  background:#fff;
  margin-left:4px;
  vertical-align:bottom;
  animation: caret 1s steps(2,end) infinite;
}
@keyframes caret {
  0%,50% { opacity:1; }
  51%,100% { opacity:0; }
}

.hero-cta {
  display:flex;
  gap:1rem;
  justify-content:center;
  flex-wrap:wrap;
}
.btn {
  --btn-bg: var(--color-accent);
  --btn-color: #fff;
  position:relative;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:.4rem;
  text-decoration:none;
  padding:.85rem 1.35rem;
  font-weight:600;
  letter-spacing:.5px;
  border-radius: var(--radius-full);
  background: var(--btn-bg);
  color: var(--btn-color);
  border:1px solid transparent;
  backdrop-filter: blur(4px);
  transition: var(--trans-fast);
  cursor:pointer;
  font-size:.95rem;
  box-shadow: 0 6px 18px -8px #000, var(--shadow-neon);
}
.btn.primary:hover {
  filter: brightness(1.15) saturate(1.2);
  transform: translateY(-2px);
}
.btn.ghost {
  --btn-bg: rgba(255,255,255,0.06);
  --btn-color: var(--color-text);
  border:1px solid var(--color-border);
  box-shadow:none;
}
.btn.ghost:hover {
  background:var(--color-accent);
  color:#fff;
}
.btn.tiny {
  font-size:.75rem;
  padding:.5rem .9rem;
  background:var(--color-surface);
}
.btn.tiny:hover {
  background:var(--color-accent);
  color:#fff;
}

.filters {
  padding: 1rem clamp(1rem, 3vw, 3rem) .5rem;
}
.tag-filter {
  display:flex;
  align-items:center;
  gap:.65rem;
  flex-wrap:wrap;
}
.filter-label {
  font-size:.8rem;
  text-transform:uppercase;
  letter-spacing:1px;
  opacity:.7;
}
.tag-chip {
  background: var(--color-surface);
  border:1px solid var(--color-border);
  padding:.45rem .9rem;
  border-radius: var(--radius-full);
  font-size:.75rem;
  letter-spacing:.5px;
  cursor:pointer;
  color: var(--color-text-dim);
  position:relative;
  transition: var(--trans-fast);
}
.tag-chip.active,
.tag-chip:hover {
  color:#fff;
  background: var(--grad-accent);
  border-color: transparent;
  box-shadow: 0 4px 14px -6px #0007, var(--shadow-neon);
}

.posts-section, .lab-section, .about-section, .contact-section {
  padding: 2rem clamp(1rem,3vw,3rem) 3rem;
  position:relative;
}
.section-title {
  margin:0 0 1.2rem;
  font-size: clamp(1.5rem,1.2rem + 1.5vw,2.3rem);
  letter-spacing:.5px;
  font-weight:600;
  background: linear-gradient(90deg,#fff,#7f99ff 60%,#ffb4e6);
  -webkit-background-clip:text;
  color:transparent;
  position:relative;
}
.section-title::after {
  content:"";
  display:block;
  margin-top:.5rem;
  width: clamp(60px, 30%, 220px);
  height:2px;
  background: var(--grad-accent);
  border-radius:4px;
  box-shadow: 0 0 12px -2px #6d8dffaa;
}

.posts-grid {
  display:grid;
  gap:1.6rem;
  grid-template-columns: repeat(auto-fit,minmax(260px,1fr));
  position:relative;
}
.post-card {
  position:relative;
  background: linear-gradient(145deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02));
  border:1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow:hidden;
  min-height: 230px;
  display:flex;
  flex-direction:column;
  transition: var(--trans-slow);
  isolation:isolate;
  backdrop-filter: blur(6px) saturate(140%);
}
.post-card::before {
  content:"";
  position:absolute; inset:0;
  background:
    radial-gradient(circle at 80% 15%,rgba(150,170,255,0.08),transparent 60%),
    linear-gradient(120deg,rgba(255,255,255,0.15),transparent 70%);
  opacity:0;
  mix-blend-mode: screen;
  transition: var(--trans-slow);
  pointer-events:none;
}
.post-card .card-link {
  flex:1; display:flex; flex-direction:column;
  color:inherit; text-decoration:none;
  padding:1rem 1rem 1.2rem;
  position:relative;
  z-index:2;
}
.post-card header {
  margin-bottom:.4rem;
}
.post-title {
  margin:.2rem 0 .35rem;
  font-size:1.05rem;
  line-height:1.35;
  font-weight:600;
}
.post-date {
  font-size:.65rem;
  text-transform:uppercase;
  letter-spacing:1px;
  color:var(--color-text-dim);
  font-family: var(--font-mono);
}
.post-excerpt {
  flex:1;
  font-size:.82rem;
  color: var(--color-text-dim);
  margin:.2rem 0 .8rem;
}
.post-tags {
  list-style:none;
  padding:0; margin:0;
  display:flex; gap:.4rem; flex-wrap:wrap;
}
.post-tags li {
  font-size:.6rem;
  letter-spacing:.5px;
  padding:.3rem .55rem;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  backdrop-filter: blur(3px);
  border:1px solid var(--color-border);
}
.post-card:hover {
  transform: translateY(-6px) scale(1.015);
  border-color: rgba(140,165,255,0.55);
  box-shadow: 0 10px 28px -10px #000a, 0 0 0 1px rgba(140,165,255,0.25), var(--shadow-neon);
}
.post-card:hover::before {
  opacity:1;
}
.post-card:hover .post-title {
  color:#fff;
}

.empty-hint {
  margin-top:2rem;
  text-align:center;
  font-size:.85rem;
  color:var(--color-text-dim);
  font-style:italic;
}

.lab-grid {
  display:grid;
  gap:1.6rem;
  grid-template-columns:repeat(auto-fit,minmax(300px,1fr));
}
.lab-item {
  background: linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02));
  border:1px solid var(--color-border);
  padding:1.1rem 1.2rem 1.3rem;
  border-radius: var(--radius-md);
  position:relative;
  overflow:hidden;
  transition: var(--trans-fast);
}
.lab-item::after {
  content:"";
  position:absolute; inset:0;
  background: radial-gradient(circle at 70% 20%, rgba(150,170,255,0.18), transparent 60%);
  opacity:0; transition: var(--trans-fast);
}
.lab-item:hover {
  transform:translateY(-4px);
  border-color:rgba(150,170,255,0.5);
  box-shadow:0 8px 24px -12px #000a, var(--shadow-neon);
}
.lab-item:hover::after { opacity:1; }
.lab-item h3 {
  margin:.2rem 0 .6rem;
  font-size:1rem;
  font-weight:600;
}
.lab-item p {
  font-size:.78rem;
  color:var(--color-text-dim);
  line-height:1.5;
  margin:0 0 1rem;
}

.about-section p, .contact-section p, .lab-section p {
  max-width:760px;
}

.contact-list {
  list-style:none; margin:0; padding:0;
  display:flex; gap:1.2rem; flex-wrap:wrap;
}
.contact-list a {
  text-decoration:none;
  color: var(--color-accent);
  font-weight:500;
  position:relative;
}
.contact-list a::after {
  content:"";
  position:absolute; left:0; bottom:-3px;
  height:1px; width:0;
  background: var(--color-accent);
  transition: var(--trans-fast);
}
.contact-list a:hover::after {
  width:100%;
}

.site-footer {
  padding:2.5rem 1.5rem 3rem;
  text-align:center;
  font-size:.7rem;
  letter-spacing:.8px;
  opacity:.75;
}
.site-footer a {
  color: var(--color-accent);
  text-decoration:none;
}
.site-footer a:hover {
  text-decoration:underline;
}

@media (max-width: 860px) {
  .nav-toggle { display:flex; }
  .nav {
    position:absolute;
    top:100%; left:0; right:0;
    background:rgba(10,15,35,0.92);
    backdrop-filter: blur(12px);
    padding:1rem clamp(1rem,4vw,2rem) 1.8rem;
    border-bottom:1px solid var(--color-border);
    transform-origin: top center;
    transform: scaleY(0);
    transition: var(--trans-fast);
    opacity:0;
  }
  .nav[data-open="true"] {
    transform: scaleY(1);
    opacity:1;
  }
  .nav ul {
    flex-direction:column;
    gap:1rem;
  }
  .hero {
    min-height: min(78vh, 740px);
  }
  .header-actions {
    margin-left:auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition: none !important;
  }
  .glitch::before,
  .glitch::after { display:none; }
}
