:root {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --radius: 12px;
  --transition: 0.2s ease;
}

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

html {
  scroll-behavior: smooth;
  /* 避免页签切换后正文高度变化时滚动条显隐，导致整页（含顶栏）横向错位 */
  scrollbar-gutter: stable;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* 导航栏 */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.navbar .logo {
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1.2;
  color: var(--text);
  white-space: nowrap;
  text-decoration: none;
}
.navbar .logo:hover { color: var(--text); }
.navbar .back-link { font-size: 0.9rem; }
/* 首页顶栏右侧外链（与历史 Hero 内按钮风格一致） */
.navbar .nav-gh {
  padding: 0.45rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  color: var(--accent);
  text-decoration: none;
  flex-shrink: 0;
  transition: border-color var(--transition), color var(--transition);
}
.navbar .nav-gh:hover {
  border-color: var(--accent);
  color: var(--accent-hover);
}

/* 首页：游戏基础库 / 作品集 / 工具插件 分页 */
.home-pages {
  min-height: 40vh;
}

.home-tabbar {
  position: sticky;
  top: 56px;
  z-index: 90;
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 2rem;
  background: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.home-tab {
  appearance: none;
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  font-size: 0.82rem;
  line-height: 1.25;
  flex: 0 0 auto;
  min-height: 2.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: border-color var(--transition), color var(--transition), background var(--transition), box-shadow var(--transition);
}
@media (min-width: 640px) {
  .home-tab {
    font-size: 0.88rem;
    padding: 0.45rem 1.15rem;
  }
}

.home-tab:hover {
  color: var(--text);
  border-color: var(--text-muted);
}
.home-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.home-tab[aria-selected="true"] {
  border-color: rgba(88, 166, 255, 0.55);
  color: var(--accent);
  background: rgba(88, 166, 255, 0.1);
  box-shadow: 0 0 0 1px rgba(88, 166, 255, 0.12);
}

.home-tabpanel[hidden] {
  display: none !important;
}

.section--home-tab {
  padding-top: 1.35rem;
  padding-bottom: 3.5rem;
}

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

.project-card-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
}
.project-card-thumb--icon {
  font-size: clamp(2.25rem, 8vw, 3rem);
}

/* 项目区域 */
.section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 2rem 5rem;
}
.section h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* 项目卡片网格 */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}
.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition), transform var(--transition);
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--text);
}
.project-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  color: var(--text);
}
.project-card img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: var(--border);
}
.project-card .card-body {
  padding: 1rem 1.25rem 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.project-card .card-title { font-size: 1rem; font-weight: 700; margin-bottom: 0.4rem; }
.project-card .card-desc { font-size: 0.875rem; color: var(--text-muted); flex: 1; }
.project-card .card-tag {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  background: rgba(88, 166, 255, 0.12);
  color: var(--accent);
}

/* 项目展示页 */
.unity-container {
  width: 100%;
  max-width: 960px;
  margin: 2rem auto;
  padding: 0 1rem;
}
.unity-container h1 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.unity-container .desc { color: var(--text-muted); margin-bottom: 1rem; font-size: 0.95rem; }
.unity-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.unity-wrapper iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* 首页：游戏基础库 — 左侧分页 + 右侧列表 */
.section--lib-split-wrap {
  max-width: 1100px;
}

.lib-split {
  display: grid;
  grid-template-columns: minmax(10.5rem, 13rem) 1fr;
  gap: 1.25rem 1.5rem;
  align-items: start;
}

.lib-split-tabs {
  position: sticky;
  top: 7.75rem;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding-top: 0.15rem;
}

.lib-split-tab {
  appearance: none;
  font: inherit;
  cursor: pointer;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  padding: 0.65rem 0.9rem;
  border-radius: 10px;
  font-size: 0.86rem;
  line-height: 1.35;
  transition: border-color var(--transition), color var(--transition), background var(--transition), box-shadow var(--transition);
}

.lib-split-tab:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.lib-split-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.lib-split-tab[aria-selected="true"] {
  border-color: rgba(88, 166, 255, 0.55);
  color: var(--accent);
  background: rgba(88, 166, 255, 0.1);
  box-shadow: 0 0 0 1px rgba(88, 166, 255, 0.12);
}

.lib-split-panels {
  min-width: 0;
}

.lib-split-panel[hidden] {
  display: none !important;
}

@media (max-width: 640px) {
  .lib-split {
    grid-template-columns: 1fr;
  }
  .lib-split-tabs {
    position: static;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 0.45rem;
    padding-bottom: 0.15rem;
    -webkit-overflow-scrolling: touch;
  }
  .lib-split-tab {
    flex: 0 0 auto;
    width: auto;
    white-space: nowrap;
  }
}

/* 库列表（紧凑行） */
.lib-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.lib-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.95rem 1.25rem;
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
  transition: background var(--transition), border-color var(--transition);
}
.lib-row + .lib-row { border-top: 1px solid var(--border); }
.lib-row:hover { background: #1c2128; }
.lib-row:hover .lib-name { color: var(--accent); }
.lib-row:hover .lib-arrow { color: var(--accent); transform: translateX(3px); }

.lib-icon { font-size: 1.4rem; flex-shrink: 0; width: 1.8rem; text-align: center; }

.lib-info { flex: 1; min-width: 0; }
.lib-name {
  font-size: 0.95rem;
  font-weight: 700;
  font-family: 'Consolas', 'SF Mono', monospace;
  margin-bottom: 0.2rem;
  transition: color var(--transition);
}
.lib-desc { font-size: 0.82rem; color: var(--text-muted); line-height: 1.4; }

.lib-tags {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}
.lib-tag {
  font-size: 0.72rem;
  padding: 0.18rem 0.5rem;
  border-radius: 4px;
  background: rgba(88,166,255,0.08);
  border: 1px solid rgba(88,166,255,0.2);
  color: var(--accent);
  white-space: nowrap;
}

.lib-arrow {
  font-size: 1rem;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: color var(--transition), transform var(--transition);
}

@media (max-width: 540px) {
  .lib-tags { display: none; }
  .lib-desc { display: none; }
}

/* 页脚 */
footer {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}
