:root {
  --bg: #0f1115;
  --bg-card: #171a21;
  --text: #e6e6e6;
  --text-dim: #9aa0ab;
  --accent: #5eead4;
  --accent-2: #818cf8;
  --border: #262b36;
  --code-bg: #1e222b;
  --max-w: 720px;
}

[data-theme="light"] {
  --bg: #fafafa;
  --bg-card: #ffffff;
  --text: #1a1a1a;
  --text-dim: #666e7a;
  --accent: #0d9488;
  --accent-2: #4f46e5;
  --border: #e5e7eb;
  --code-bg: #f3f4f6;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.75;
  transition: background 0.3s, color 0.3s;
  -webkit-font-smoothing: antialiased;
}

/* ---------- A11y ---------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 0 0 8px 0;
  padding: 0.6rem 1rem;
  text-decoration: none;
}
.skip-link:focus { left: 0; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

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

/* ---------- Header ---------- */
header {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  border-bottom: 1px solid var(--border);
}

.nav {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0.9rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-weight: 700;
  font-size: 1.15rem;
  text-decoration: none;
  color: var(--text);
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-right { display: flex; align-items: center; gap: 1rem; }

.nav a.nav-link {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.92rem;
  transition: color 0.2s;
}
.nav a.nav-link:hover { color: var(--accent); }

#theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  padding: 0.3rem 0.55rem;
  font-size: 1rem;
  line-height: 1;
  transition: border-color 0.2s;
}
#theme-toggle:hover { border-color: var(--accent); }

/* ---------- Layout ---------- */
main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

/* ---------- Hero ---------- */
.hero { margin-bottom: 2.5rem; }
.hero h1 {
  font-size: 2rem;
  line-height: 1.3;
  margin-bottom: 0.5rem;
}
.hero p { color: var(--text-dim); }

.hero-profile {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.avatar {
  width: 88px;
  height: 88px;
  flex-shrink: 0;
  border-radius: 50%;
}
.social-links { margin-top: 0.7rem; display: flex; gap: 1rem; flex-wrap: wrap; }
.social-links a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.88rem;
  border-bottom: 1px dashed var(--border);
}
.social-links a:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- Search ---------- */
#search {
  width: 100%;
  margin-bottom: 2rem;
  padding: 0.7rem 1rem;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.2s;
}
#search:focus { border-color: var(--accent); }
#search::placeholder { color: var(--text-dim); }

#search-empty { color: var(--text-dim); }

/* ---------- Post list ---------- */
.post-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.4rem 1.6rem;
  margin-bottom: 1.1rem;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
/* display:block 会盖掉 [hidden] 的默认样式，搜索过滤要靠这条才生效 */
.post-card[hidden] { display: none; }
.post-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.15);
}
.post-card h2 { font-size: 1.2rem; margin-bottom: 0.35rem; }
.post-card p { color: var(--text-dim); font-size: 0.92rem; }

.post-meta {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.7rem;
}

.tag {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  border-radius: 6px;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
}

/* ---------- Article ---------- */
article h1 { font-size: 1.9rem; line-height: 1.35; margin-bottom: 0.6rem; }
article .post-meta { margin-bottom: 2.2rem; }
article h2 { margin: 2.2rem 0 0.8rem; font-size: 1.35rem; }
article h3 { margin: 1.6rem 0 0.6rem; font-size: 1.1rem; }
article h4 { margin: 1.4rem 0 0.5rem; font-size: 1rem; }
article p { margin-bottom: 1.1rem; }
article ul, article ol { margin: 0 0 1.1rem 1.4rem; }
article li { margin: 0.25em 0; }
article a { color: var(--accent); }
article blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.2rem 0 0.2rem 1rem;
  color: var(--text-dim);
  margin-bottom: 1.1rem;
}
article blockquote > *:last-child { margin-bottom: 0; }
article img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  display: block;
  margin: 1.2rem auto;
}
article hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}
article del { color: var(--text-dim); }

article table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.3rem;
  font-size: 0.9rem;
}
article th, article td {
  border-bottom: 1px solid var(--border);
  padding: 0.55rem 0.7rem;
  text-align: left;
}
article th { color: var(--text); font-weight: 600; }
article td { color: var(--text-dim); }
article tbody tr:last-child td { border-bottom: none; }

article code {
  font-family: "SF Mono", "JetBrains Mono", Consolas, monospace;
  background: var(--code-bg);
  border-radius: 6px;
  padding: 0.15rem 0.4rem;
  font-size: 0.88em;
}
article pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  overflow-x: auto;
  margin-bottom: 1.1rem;
}
article pre code { background: none; padding: 0; font-size: 0.85em; }

.back-link {
  display: inline-block;
  margin-bottom: 1.6rem;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
}
.back-link:hover { color: var(--accent); }

.notfound { text-align: center; padding: 3rem 0; }
.notfound h1 {
  font-size: 4rem;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.notfound p { color: var(--text-dim); }

/* ---------- Footer ---------- */
footer {
  border-top: 1px solid var(--border);
  padding: 1.6rem 1.25rem;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .hero h1 { font-size: 1.6rem; }
  article h1 { font-size: 1.5rem; }
  .post-card { padding: 1.1rem 1.2rem; }
  .hero-profile { flex-direction: column; align-items: flex-start; gap: 1rem; }
  article table { display: block; overflow-x: auto; }
}

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