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

:root {
  --bg: #0a0e14;
  --bg2: #0f141d;
  --card: #131a26;
  --line: rgba(120, 160, 255, 0.12);
  --txt: #e6ecf5;
  --dim: #8b98ad;
  --acc: #5b8cff;
  --acc2: #38e0c8;
  --grad: linear-gradient(120deg, #5b8cff, #38e0c8);
  --nav-bg: rgba(10, 14, 20, 0.7);
  --glow1: rgba(91, 140, 255, 0.15);
  --glow2: rgba(56, 224, 200, 0.12);
  --ic-bg: rgba(91, 140, 255, 0.12);
}

[data-theme="light"] {
  --bg: #f5f7fb;
  --bg2: #eceff6;
  --card: #ffffff;
  --line: rgba(30, 60, 120, 0.12);
  --txt: #1a2333;
  --dim: #5a6a82;
  --nav-bg: rgba(245, 247, 251, 0.75);
  --glow1: rgba(91, 140, 255, 0.18);
  --glow2: rgba(56, 224, 200, 0.16);
  --ic-bg: rgba(91, 140, 255, 0.10);
}

body {
  background: var(--bg);
  color: var(--txt);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.7;
  transition: background 0.3s, color 0.3s;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

/* nav */
nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  backdrop-filter: blur(14px);
  background: var(--nav-bg);
  border-bottom: 1px solid var(--line);
}

nav .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 2px;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

nav ul {
  display: flex;
  gap: 28px;
  list-style: none;
  font-size: 14px;
  color: var(--dim);
}

nav ul a:hover {
  color: var(--txt);
}

@media (max-width: 640px) {
  nav ul {
    display: none;
  }
}

#theme-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--txt);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.25s;
}

#theme-btn:hover {
  border-color: var(--acc);
  background: var(--ic-bg);
}

#theme-btn .material-icons {
  font-size: 20px;
}

/* hero - 关键修改：所有元素固定位置 */
header {
  min-height: 100vh;
  display: flex;
  align-items: center;
  position: relative;
  padding-top: 60px;
}

header::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(600px 400px at 20% 30%, var(--glow1), transparent 60%),
    radial-gradient(500px 400px at 80% 70%, var(--glow2), transparent 60%);
}

.grid-bg {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
}

header .wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 70vh;
}

/* 标签 - 固定 */
.tag {
  display: inline-block;
  font-size: 13px;
  color: var(--acc2);
  border: 1px solid rgba(56, 224, 200, 0.35);
  padding: 4px 14px;
  border-radius: 99px;
  margin-bottom: 24px;
  flex-shrink: 0;
}

/* 标题 - 固定 */
h1 {
  font-size: clamp(38px, 7vw, 72px);
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: 1px;
  flex-shrink: 0;
  margin-bottom: 22px;
}

h1 span {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* 打字机容器 - 完全固定高度，不会抖动 */
.typer-wrapper {
  height: 3.4em;
  min-height: 3.4em;
  max-height: 3.4em;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-bottom: 36px;
}

.sub {
  color: var(--dim);
  max-width: 560px;
  font-size: 17px;
  line-height: 1.7;
  margin: 0;
  padding: 0;
}

.caret {
  display: inline-block;
  color: var(--acc);
  font-weight: 700;
  animation: blink 0.8s step-end infinite;
  margin-left: 2px;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* 按钮 - 固定 */
.btns {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.btn {
  padding: 13px 30px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  transition: 0.25s;
}

.btn-p {
  background: var(--grad);
  color: #06121a;
}

.btn-p:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(91, 140, 255, 0.35);
}

.btn-g {
  border: 1px solid var(--line);
  color: var(--txt);
}

.btn-g:hover {
  border-color: var(--acc);
  background: rgba(91, 140, 255, 0.08);
}

/* sections */
section {
  padding: 96px 0;
}

.sec-h {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 8px;
}

.sec-d {
  color: var(--dim);
  margin-bottom: 48px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  transition: 0.25s;
}

.card:hover {
  transform: translateY(-4px);
  border-color: rgba(91, 140, 255, 0.4);
}

.card .ic {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--ic-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 16px;
}

.card .ic .material-icons {
  font-size: 24px;
  color: var(--acc);
}

.card h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.card p {
  color: var(--dim);
  font-size: 14px;
}

/* principles */
.prin {
  counter-reset: c;
}

.prin .card {
  position: relative;
  padding-top: 56px;
}

.prin .card::before {
  counter-increment: c;
  content: "0" counter(c);
  position: absolute;
  top: 20px;
  left: 28px;
  font-size: 14px;
  font-weight: 800;
  color: var(--acc);
  letter-spacing: 2px;
}

/* projects - GitHub repo cards */
.proj {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.proj .card {
  display: flex;
  flex-direction: column;
}

.badge {
  align-self: flex-start;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 99px;
  margin-bottom: 14px;
  background: rgba(91, 140, 255, 0.15);
  color: var(--acc);
  border: none;
}

.repo-star {
  margin-left: auto;
  font-weight: 400;
  color: var(--dim);
  font-size: 13px;
}

.proj .card p {
  flex: 1;
}

.proj a.link {
  font-size: 14px;
  color: var(--acc);
  margin-top: 14px;
  word-break: break-all;
}

.proj a.link:hover {
  text-decoration: underline;
}

.repo-loading, .repo-error {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 0;
  color: var(--dim);
  font-size: 15px;
}
.repo-error {
  color: #f28b82;
}

/* community */
.comm {
  background: var(--bg2);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.comm-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 48px;
  align-items: center;
}

@media (max-width: 760px) {
  .comm-grid {
    grid-template-columns: 1fr;
  }
}

.qq {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 3px;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin: 8px 0 4px;
}

.note {
  font-size: 13px;
  color: var(--dim);
}

.rules {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rules li {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 14px;
  color: var(--dim);
}

.rules b {
  color: var(--txt);
}

footer {
  padding: 40px 0;
  text-align: center;
  color: var(--dim);
  font-size: 13px;
  border-top: 1px solid var(--line);
}

footer .motto {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 700;
  margin-bottom: 6px;
}