/* ============================================
   极简双主题 · 主样式
   结构：变量 → 基础 → 布局 → 组件 → 页面 → 响应式
   ============================================ */

/* ---------- 1. 主题变量 ---------- */
:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --surface: #ffffff;
  --text: #18181b;
  --text-soft: #52525b;
  --text-mute: #8b8b95;
  --border: #e6e6ea;
  --border-strong: #d3d3da;
  --accent: #2f5fe0;
  --accent-soft: rgba(47, 95, 224, 0.08);
  --accent-text: #ffffff;
  --code-bg: #f4f4f6;
  --mark: #fff3c4;
  --shadow: 0 1px 2px rgba(16, 16, 24, 0.04), 0 8px 24px rgba(16, 16, 24, 0.05);
  --radius: 12px;
  --radius-sm: 8px;
  --maxw: 860px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
  --header-h: 58px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0c0c0e;
  --bg-soft: #121215;
  --surface: #151518;
  --text: #ececef;
  --text-soft: #b4b4bd;
  --text-mute: #82828d;
  --border: #26262c;
  --border-strong: #35353d;
  --accent: #7d9cf5;
  --accent-soft: rgba(125, 156, 245, 0.12);
  --accent-text: #0c0c0e;
  --code-bg: #1b1b20;
  --mark: #4a3f12;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

/* ---------- 2. 基础 ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

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

h1, h2, h3, h4 { line-height: 1.3; font-weight: 650; letter-spacing: -0.01em; margin: 0 0 .5em; }
h1 { font-size: clamp(1.8rem, 4.5vw, 2.5rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.08rem; }
p { margin: 0 0 1.1em; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.1em 0.38em;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.6;
}
pre code { background: none; border: 0; padding: 0; font-size: inherit; }

mark { background: var(--mark); color: var(--text); padding: 0 0.2em; border-radius: 3px; }

hr { border: 0; border-top: 1px solid var(--border); margin: 2.4rem 0; }

img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--accent-soft); }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--accent-text); padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* ---------- 3. 布局 ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.wrap-wide { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap-wide {
  height: 100%;
  display: flex; align-items: center; gap: 20px;
}

.brand {
  font-weight: 700; font-size: 0.98rem; color: var(--text);
  display: inline-flex; align-items: center; gap: 8px;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #8b5cf6));
  display: inline-block;
}

.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav a {
  color: var(--text-soft); font-size: 0.9rem;
  padding: 6px 11px; border-radius: 7px;
}
.nav a:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--accent-soft); font-weight: 550; }

.theme-toggle {
  width: 34px; height: 34px; flex: 0 0 34px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-soft);
  border-radius: 9px; cursor: pointer; font-size: 0.95rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}
.theme-toggle:hover { border-color: var(--border-strong); color: var(--text); }

main { min-height: calc(100vh - var(--header-h) - 92px); }
.section { padding: 56px 0; }
.section--tight { padding: 36px 0; }
.section-head { margin-bottom: 28px; }
.section-head p { color: var(--text-soft); margin: 0; }
.eyebrow {
  font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--text-mute); font-weight: 600; margin: 0 0 8px;
}

/* ---------- 4. 组件 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.card--link:hover {
  text-decoration: none; border-color: var(--border-strong);
  transform: translateY(-2px); box-shadow: var(--shadow);
}
.card h3 { margin-bottom: 6px; }
.card p { color: var(--text-soft); font-size: 0.92rem; margin: 0; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 17px; border-radius: 9px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-size: 0.9rem; font-family: inherit; cursor: pointer;
  transition: background-color 0.18s, border-color 0.18s, color 0.18s;
}
.btn:hover { background: var(--bg-soft); text-decoration: none; }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 550;
}
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 86%, #000); color: var(--accent-text); }
.btn-sm { padding: 5px 11px; font-size: 0.82rem; border-radius: 7px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

.tag {
  display: inline-block; font-size: 0.74rem; line-height: 1.6;
  padding: 1px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  white-space: nowrap;
}
.tag-plain { background: var(--bg-soft); color: var(--text-mute); border-color: var(--border); }

.meta { color: var(--text-mute); font-size: 0.83rem; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.pill-row { display: flex; flex-wrap: wrap; gap: 7px; }

.lab-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; overflow: hidden;
}
.lab-panel header { margin-bottom: 14px; }
.lab-panel h3 { margin: 0 0 3px; font-size: 1rem; }
.lab-panel header p { margin: 0; font-size: 0.84rem; color: var(--text-mute); }

.stat { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--bg-soft); }
.stat .k { font-size: 0.74rem; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.08em; }
.stat .v { font-family: var(--mono); font-size: 1.05rem; font-weight: 600; margin-top: 2px; }

.notice {
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  padding: 12px 16px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.9rem; color: var(--text-soft);
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 26px 0 32px;
  margin-top: 24px;
  color: var(--text-mute); font-size: 0.84rem;
}
.site-footer .foot-inner { display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: space-between; align-items: center; }
.site-footer a { color: var(--text-soft); }
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; }

input[type="text"], input[type="search"], textarea, select {
  width: 100%; font-family: inherit; font-size: 0.9rem;
  padding: 9px 12px; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  transition: border-color 0.18s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: none; }
label { font-size: 0.83rem; color: var(--text-soft); display: block; margin-bottom: 5px; }
.field { margin-bottom: 12px; }

/* ---------- 5. 首页 ---------- */
.hero { padding: 72px 0 56px; border-bottom: 1px solid var(--border); }
.hero h1 { margin-bottom: 14px; }
.hero .lede { font-size: 1.03rem; color: var(--text-soft); max-width: 60ch; }
.hero .status {
  display: inline-flex; align-items: center; gap: 7px; margin-bottom: 20px;
  font-size: 0.8rem; color: var(--text-mute);
  border: 1px solid var(--border); border-radius: 999px; padding: 3px 12px;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.16); }

.stack-row { display: flex; flex-wrap: wrap; gap: 8px; }
.stack-item {
  font-size: 0.84rem; padding: 5px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--text-soft);
}
.stack-item b { color: var(--text); font-weight: 600; }

.timeline { border-left: 2px solid var(--border); padding-left: 20px; }
.timeline-item { position: relative; padding-bottom: 18px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: ""; position: absolute; left: -26px; top: 7px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--accent);
}
.timeline-item .when { font-size: 0.78rem; color: var(--text-mute); font-family: var(--mono); }
.timeline-item .what { font-weight: 550; }

/* ---------- 6. 实验室 ---------- */
.lab-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.canvas-box {
  width: 100%; height: 220px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-soft); display: block;
}
.flip-scene { perspective: 900px; height: 200px; display: flex; align-items: center; justify-content: center; }
.flip-card {
  width: 180px; height: 200px; position: relative;
  transform-style: preserve-3d; transition: transform 0.7s cubic-bezier(.2,.7,.3,1);
  cursor: pointer;
}
.flip-card.flipped { transform: rotateY(180deg); }
.flip-face {
  position: absolute; inset: 0; backface-visibility: hidden;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 16px; text-align: center;
}
.flip-face.back { transform: rotateY(180deg); background: var(--accent-soft); border-color: var(--accent); }
.flip-face .big { font-size: 1.5rem; font-weight: 700; }
.flip-face small { color: var(--text-mute); }

.terminal {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px;
  font-family: var(--mono); font-size: 0.84rem; line-height: 1.75;
  height: 200px; overflow-y: auto; color: var(--text-soft);
}
.terminal .ok { color: #22c55e; }
.terminal .warn { color: #f59e0b; }
html[data-theme="dark"] .terminal .ok { color: #4ade80; }
.terminal-line { white-space: pre-wrap; word-break: break-word; }

.progress { height: 7px; border-radius: 999px; background: var(--code-bg); overflow: hidden; border: 1px solid var(--border); }
.progress > i { display: block; height: 100%; width: 0%; background: var(--accent); transition: width 0.25s ease; }

.todo-list { list-style: none; margin: 10px 0 0; padding: 0; }
.todo-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 0.9rem;
}
.todo-list li:last-child { border-bottom: 0; }
.todo-list li.done span { text-decoration: line-through; color: var(--text-mute); }
.todo-list input { width: auto; margin: 0; }

/* ---------- 7. 博客 ---------- */
.post-list { display: flex; flex-direction: column; gap: 0; }
.post-item {
  display: block; padding: 20px 0; border-bottom: 1px solid var(--border); color: inherit;
}
.post-item:hover { text-decoration: none; }
.post-item:hover .post-title { color: var(--accent); }
.post-title { font-size: 1.06rem; font-weight: 620; margin: 0 0 6px; transition: color 0.15s; }
.post-item p { margin: 0 0 8px; color: var(--text-soft); font-size: 0.9rem; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 24px; }
.filter-btn {
  font: inherit; font-size: 0.83rem; cursor: pointer;
  padding: 5px 13px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-soft);
  transition: all 0.16s;
}
.filter-btn:hover { border-color: var(--border-strong); color: var(--text); }
.filter-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.prose { font-size: 1rem; }
.prose h2 { margin-top: 2rem; padding-top: 0.2rem; }
.prose h3 { margin-top: 1.5rem; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 1.1em; }
.prose li { margin-bottom: 0.35em; }
.prose blockquote {
  margin: 1.3em 0; padding: 2px 16px;
  border-left: 3px solid var(--border-strong); color: var(--text-soft);
}
.prose table { width: 100%; border-collapse: collapse; margin: 1.3em 0; font-size: 0.9rem; }
.prose th, .prose td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.prose th { background: var(--bg-soft); font-weight: 600; }

.post-nav {
  display: flex; justify-content: space-between; gap: 12px;
  margin-top: 44px; padding-top: 20px; border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

/* ---------- 8. 响应式 ---------- */
@media (max-width: 640px) {
  .hero { padding: 48px 0 38px; }
  .section { padding: 40px 0; }
  .nav a { padding: 6px 8px; font-size: 0.86rem; }
  .site-footer .foot-inner { flex-direction: column; align-items: flex-start; }
  .post-nav { flex-direction: column; }
}

/* ---------- 9. 打印 ---------- */
@media print {
  .site-header, .site-footer, .nav, .theme-toggle, .filters { display: none !important; }
  body { background: #fff; color: #000; }
}
