/* ==========================================================================
   站点样式：默认深色，可切换浅色。颜色集中在 :root 与 [data-theme="light"] 里。
   ========================================================================== */

:root {
  --bg: #0c0f14;
  --bg-grad: radial-gradient(1200px 600px at 15% -10%, rgba(94, 234, 212, 0.10), transparent 60%),
             radial-gradient(900px 500px at 100% 0%, rgba(125, 211, 252, 0.08), transparent 55%);
  --surface: #12161d;
  --surface-2: #171c25;
  --border: #232a36;
  --border-strong: #2f3846;
  --text: #e7ebf2;
  --text-soft: #c3cad6;
  --muted: #8b95a5;
  --brand: #5eead4;
  --brand-soft: rgba(94, 234, 212, 0.12);
  --brand-text: #0c0f14;
  --danger: #f87171;
  --ok: #4ade80;
  --radius: 14px;
  --radius-sm: 9px;
  --maxw: 780px;
  --shadow: 0 10px 30px -18px rgba(0, 0, 0, 0.85);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

html[data-theme="light"] {
  --bg: #fbfbfd;
  --bg-grad: radial-gradient(1100px 520px at 12% -12%, rgba(13, 148, 136, 0.10), transparent 60%),
             radial-gradient(900px 460px at 100% 0%, rgba(2, 132, 199, 0.08), transparent 55%);
  --surface: #ffffff;
  --surface-2: #f6f7fa;
  --border: #e6e8ee;
  --border-strong: #d5d9e2;
  --text: #1c2230;
  --text-soft: #3d4557;
  --muted: #6b7488;
  --brand: #0d9488;
  --brand-soft: rgba(13, 148, 136, 0.10);
  --brand-text: #ffffff;
  --danger: #dc2626;
  --shadow: 0 10px 30px -20px rgba(16, 24, 40, 0.35);
}

* { box-sizing: border-box; }

/* 显式让 hidden 属性生效：.cf-reply 的 display:flex、.btn 的 display:inline-flex
   都会盖掉浏览器默认的 [hidden]{display:none}，不补这条就会出现「明明 hidden 了还显示」 */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background-color: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

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

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

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

.skip {
  position: absolute; left: -9999px; top: 0; padding: 8px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 0 0 var(--radius-sm) 0;
}
.skip:focus { left: 0; z-index: 50; }

/* ---------- 页头 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 16px; min-height: 68px; }

.brand { display: flex; align-items: center; gap: 12px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-text strong { font-size: 16px; letter-spacing: 0.02em; }
.brand-text em { font-style: normal; font-size: 12px; color: var(--muted); }

.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 600; font-size: 15px; color: var(--brand-text);
  background: linear-gradient(140deg, var(--brand), #7dd3fc);
  flex: none;
}
.avatar-lg { width: 76px; height: 76px; font-size: 30px; }
img.avatar { object-fit: cover; }

.site-nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.site-nav a {
  color: var(--text-soft); font-size: 14px; padding: 7px 12px; border-radius: 999px;
}
.site-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.site-nav a.active { color: var(--brand); background: var(--brand-soft); }

.theme-toggle {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); color: var(--text-soft);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 10px; font-size: 12px; font-family: inherit; cursor: pointer;
}
.theme-toggle:hover { border-color: var(--border-strong); color: var(--text); }
html[data-theme="dark"] .theme-toggle .t-dark,
html[data-theme="light"] .theme-toggle .t-light { color: var(--brand); font-weight: 600; }

/* ---------- 通用 ---------- */
main { display: block; padding-top: 34px; padding-bottom: 60px; }
.muted { color: var(--muted); }
.section-title {
  font-size: 15px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); margin: 44px 0 18px; font-weight: 600;
}
.section-title .count { margin-left: 8px; color: var(--brand); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 999px; font-size: 14px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  cursor: pointer; font-family: inherit; transition: border-color .15s, background .15s, transform .1s;
}
.btn:hover { border-color: var(--brand); color: var(--text); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-text); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.link-btn {
  background: none; border: none; padding: 0; font: inherit; color: var(--brand); cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}

/* ---------- 首页 ---------- */
.profile-card {
  display: flex; align-items: center; gap: 22px;
  padding: 26px; border: 1px solid var(--border); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface), var(--bg));
  box-shadow: var(--shadow);
}
.profile-text h1 { margin: 0 0 6px; font-size: 24px; letter-spacing: 0.01em; }
.profile-bio { margin: 0 0 14px; color: var(--text-soft); font-size: 15px; }
.profile-links { margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.profile-links .btn { padding: 6px 14px; font-size: 13px; }

.post-card {
  position: relative;
  padding: 20px 22px; margin-bottom: 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); transition: border-color .18s, transform .18s, box-shadow .18s;
}
.post-card:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow); }
.post-card::before {
  content: ""; position: absolute; left: 0; top: 20px; bottom: 20px; width: 2px;
  background: var(--brand); border-radius: 2px; opacity: 0; transition: opacity .18s;
}
.post-card:hover::before { opacity: 1; }
.post-link { display: block; color: inherit; }
.post-link:hover { text-decoration: none; }
.post-title { margin: 0 0 8px; font-size: 19px; line-height: 1.5; }
.post-card:hover .post-title { color: var(--brand); }
.post-summary { margin: 0; color: var(--muted); font-size: 14.5px; }
.post-meta {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  margin-top: 14px; font-size: 12.5px; color: var(--muted);
}
.dot { opacity: .6; }
.post-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px;
  color: var(--text-soft); background: var(--surface-2); border: 1px solid var(--border);
}
.tag:hover { color: var(--brand); border-color: var(--brand); text-decoration: none; }
.tag-n { color: var(--muted); font-size: 11px; }

.more-link { text-align: center; margin-top: 26px; }

.page-head { margin-bottom: 34px; }
.page-head h1 { margin: 0 0 6px; font-size: 26px; }
.page-head .muted { margin: 0; font-size: 13px; }

.archive-year h2 { font-size: 15px; color: var(--muted); font-weight: 600; margin: 26px 0 10px; }
.archive-list { list-style: none; margin: 0; padding: 0; }
.archive-list li { border-bottom: 1px dashed var(--border); }
.archive-list a { display: flex; gap: 14px; align-items: baseline; padding: 10px 4px; color: var(--text-soft); }
.archive-list a:hover { color: var(--brand); text-decoration: none; }
.archive-list time { color: var(--muted); font-size: 12.5px; font-family: var(--font-mono); flex: none; }
.a-title { font-size: 15px; }

.tag-cloud { margin-top: 46px; }
.tag-cloud p { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 30px; font-size: 14px; }
.pg { padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px; color: var(--text-soft); }
.pg:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.pg.disabled { opacity: .45; }
.pg-info { color: var(--muted); font-size: 13px; }

/* ---------- 文章 ---------- */
.post-header { margin-bottom: 30px; }
.post-header h1 { margin: 0 0 12px; font-size: 30px; line-height: 1.4; letter-spacing: 0.01em; }

.post-body { font-size: 16.5px; color: var(--text-soft); }
.post-body > *:first-child { margin-top: 0; }
.post-body p { margin: 0 0 18px; }
.post-body h2 {
  position: relative; margin: 40px 0 16px; padding-left: 14px;
  font-size: 21px; color: var(--text); line-height: 1.5;
}
.post-body h2::before {
  content: ""; position: absolute; left: 0; top: .38em; width: 3px; height: 1em;
  background: var(--brand); border-radius: 3px;
}
.post-body h3 { margin: 30px 0 12px; font-size: 18px; color: var(--text); }
.post-body h4 { margin: 24px 0 10px; font-size: 16px; color: var(--text); }
.post-body ul, .post-body ol { margin: 0 0 18px; padding-left: 22px; }
.post-body li { margin: 6px 0; }
.post-body li > ul, .post-body li > ol { margin: 6px 0; }
.post-body strong { color: var(--text); }
.post-body a { border-bottom: 1px solid var(--brand-soft); }

.post-body blockquote {
  margin: 22px 0; padding: 4px 18px;
  border-left: 3px solid var(--brand);
  background: var(--brand-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-soft);
}
.post-body blockquote p:last-child { margin-bottom: 0; }

.post-body code {
  font-family: var(--font-mono); font-size: .88em;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 6px; color: var(--text);
}

.code-block {
  position: relative; margin: 22px 0; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  background: var(--surface-2);
}
.code-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 12px; border-bottom: 1px solid var(--border);
  background: var(--surface); min-height: 34px;
}
.code-lang { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); text-transform: lowercase; }
.code-copy {
  background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: 6px; padding: 3px 9px; font-size: 11.5px; font-family: inherit; cursor: pointer;
}
.code-copy:hover { color: var(--brand); border-color: var(--brand); }
.code-block pre { margin: 0; padding: 16px 18px; overflow-x: auto; }
.code-block code {
  font-family: var(--font-mono); font-size: 13.5px; line-height: 1.7;
  background: none; border: none; padding: 0; color: var(--text); white-space: pre;
}

.table-wrap { margin: 22px 0; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.post-body table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.post-body th, .post-body td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.post-body th { background: var(--surface-2); color: var(--text); font-weight: 600; }
.post-body tbody tr:last-child td { border-bottom: none; }
.post-body tbody tr:hover td { background: var(--surface-2); }

.post-body img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }
.post-body hr { border: none; border-top: 1px solid var(--border); margin: 32px 0; }

.post-nav {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  margin: 44px 0 0; padding-top: 26px; border-top: 1px solid var(--border);
}
.pn {
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
}
.pn:hover { border-color: var(--brand); text-decoration: none; }
.pn span { font-size: 12px; color: var(--muted); }
.pn b { font-size: 14.5px; font-weight: 500; }
.pn.next { text-align: right; }

/* ---------- 留言 ---------- */
.comments { margin-top: 52px; }

.comment-form {
  padding: 20px; margin-bottom: 30px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.cf-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cf-field { display: block; margin-bottom: 14px; }
.cf-field > span { display: block; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.cf-field > span i { color: var(--brand); font-style: normal; }
.cf-field input, .cf-field textarea {
  width: 100%; padding: 10px 12px; font-family: inherit; font-size: 14.5px;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: border-color .15s, background .15s;
}
.cf-field textarea { resize: vertical; min-height: 110px; line-height: 1.7; }
.cf-field input::placeholder, .cf-field textarea::placeholder { color: var(--muted); opacity: .8; }
.cf-field input:focus, .cf-field textarea:focus { border-color: var(--brand); outline: none; }
.cf-field.invalid input, .cf-field.invalid textarea { border-color: var(--danger); }
.cf-error { display: block; margin-top: 5px; font-size: 12.5px; color: var(--danger); }

.cf-reply {
  display: flex; align-items: center; gap: 10px; margin: 0 0 12px;
  padding: 8px 12px; font-size: 13px; color: var(--text-soft);
  background: var(--brand-soft); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.cf-reply b { color: var(--brand); }

.cf-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cf-hint { font-size: 12.5px; color: var(--muted); }
.cf-count { margin-left: auto; font-size: 12px; color: var(--muted); font-family: var(--font-mono); }
.cf-msg { margin: 12px 0 0; font-size: 13.5px; min-height: 0; }
.cf-msg.error { color: var(--danger); }
.cf-msg.ok { color: var(--ok); }

.cf-honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.comment-list { list-style: none; margin: 0; padding: 0; }
.comment-list > .comment {
  display: flex; gap: 14px; padding: 18px 0;
  border-top: 1px solid var(--border);
}
.comment-empty { padding: 26px 0; color: var(--muted); font-size: 14px; border-top: 1px solid var(--border); }

.c-avatar {
  width: 38px; height: 38px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-size: 15px; font-weight: 600; color: #fff;
  background: var(--avatar, #64748b);
}
.c-body { flex: 1; min-width: 0; }
.c-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.c-author { font-weight: 600; font-size: 14.5px; color: var(--text); }
.c-time { font-size: 12px; color: var(--muted); }
.c-content { margin-top: 6px; font-size: 15px; color: var(--text-soft); overflow-wrap: anywhere; }
.c-content code {
  font-family: var(--font-mono); font-size: .88em;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px;
}
.c-actions { margin-top: 8px; }
.c-reply {
  background: none; border: none; padding: 0; font: inherit; font-size: 12.5px;
  color: var(--muted); cursor: pointer;
}
.c-reply:hover { color: var(--brand); }

.c-children { list-style: none; margin: 14px 0 0; padding: 0 0 0 14px; border-left: 2px solid var(--border); }
.c-children > .comment { display: flex; gap: 12px; padding: 12px 0; }
.c-children > .comment:first-child { padding-top: 4px; }
.c-children .c-avatar { width: 30px; height: 30px; font-size: 13px; }
.c-children .c-content { font-size: 14.5px; }

.load-more-wrap { text-align: center; margin-top: 26px; }

/* ---------- 其它 ---------- */
.empty-state { text-align: center; padding: 80px 0; }
.empty-state h1 { font-size: 56px; margin: 0 0 10px; color: var(--brand); }
.empty-state p { color: var(--muted); }

.site-footer { border-top: 1px solid var(--border); padding: 34px 0 44px; margin-top: 40px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.chip {
  padding: 5px 12px; border-radius: 999px; font-size: 13px;
  color: var(--text-soft); background: var(--surface); border: 1px solid var(--border);
}
.chip:hover { color: var(--brand); border-color: var(--brand); text-decoration: none; }
.footer-meta { margin: 0; font-size: 12.5px; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  padding: 10px 18px; border-radius: 999px; font-size: 14px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.comment:target .c-content { animation: flash 1.6s ease-out; }
@keyframes flash {
  from { background: var(--brand-soft); }
  to { background: transparent; }
}

/* ---------- 小屏 ---------- */
@media (max-width: 640px) {
  body { font-size: 15.5px; }
  .header-inner { flex-wrap: wrap; gap: 8px; padding-top: 10px; padding-bottom: 10px; }
  .brand-text em { display: none; }
  .site-nav { margin-left: auto; }
  .site-nav a { padding: 6px 9px; font-size: 13px; }
  .theme-toggle { padding: 6px 8px; }
  .profile-card { flex-direction: column; align-items: flex-start; gap: 16px; padding: 20px; }
  .avatar-lg { width: 60px; height: 60px; font-size: 24px; }
  .profile-text h1 { font-size: 21px; }
  .post-header h1 { font-size: 24px; }
  .post-body h2 { font-size: 19px; }
  .post-tags { margin-left: 0; width: 100%; }
  .cf-row { grid-template-columns: 1fr; gap: 0; }
  .cf-foot { gap: 8px; }
  .cf-count { margin-left: 0; }
  .post-nav { grid-template-columns: 1fr; }
  .pn.next { text-align: left; }
}

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