@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --bg:           #ffffff;
  --bg-alt:       #f8f9fb;
  --bg-card:      #ffffff;
  --border:       #eaecf0;
  --text:         #111827;
  --text-muted:   #6b7280;
  --text-light:   #9ca3af;
  --accent:       #4f6ef7;
  --accent-dark:  #3b55d9;
  --accent-light: #eef1fe;
  --tag-bg:       #f0f3ff;
  --tag-text:     #4f6ef7;
  --code-bg:      #f5f7fa;
  --code-border:  #e4e7ec;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:    0 4px 16px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.04);
  --radius:       12px;
  --radius-sm:    8px;
  --max-w:        1100px;
  --content-w:    680px;   /* 文章正文阅读宽度 */
  --header-h:     64px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
          'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
}

/* ── Dark Mode ─────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:           #0f1117;
    --bg-alt:       #161b27;
    --bg-card:      #161b27;
    --border:       #1f2937;
    --text:         #f0f1f3;
    --text-muted:   #8b95a7;
    --text-light:   #4b5563;
    --accent:       #6b83fa;
    --accent-dark:  #8398fb;
    --accent-light: #1a2040;
    --tag-bg:       #1a2040;
    --tag-text:     #7b94fb;
    --code-bg:      #1a1f2e;
    --code-border:  #252d3d;
    --shadow-sm:    0 1px 3px rgba(0,0,0,.3);
    --shadow-md:    0 4px 20px rgba(0,0,0,.4);
  }
}

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }

/* ── Header ────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.site-logo {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.4px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}
.site-logo:hover { text-decoration: none; color: var(--accent); }
.logo-dot {
  display: inline-block;
  width: 7px; height: 7px;
  background: var(--accent);
  border-radius: 50%;
  margin-bottom: 1px;
}

.site-nav { display: flex; gap: 2px; }

.nav-link {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: background .15s, color .15s;
}
.nav-link:hover,
.nav-link.active {
  background: var(--accent-light);
  color: var(--accent);
  text-decoration: none;
}

/* ── Container ─────────────────────────────────────────────── */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 40px;
  flex: 1;
}

/* ── 两栏布局（PC 博客列表 & 文章页）─────────────────────────── */
.layout-two-col {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 48px;
  align-items: start;
}
.layout-main  { min-width: 0; }
.layout-aside { position: sticky; top: calc(var(--header-h) + 24px); }

/* 侧边栏卡片 */
.aside-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.aside-card h3 {
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.aside-tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }

/* 侧边栏文章列表 */
.aside-post-list { list-style: none; }
.aside-post-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: .875rem;
}
.aside-post-list li:last-child { border-bottom: none; padding-bottom: 0; }
.aside-post-list a {
  color: var(--text);
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.45;
  transition: color .15s;
}
.aside-post-list a:hover { color: var(--accent); text-decoration: none; }
.aside-post-list .aside-post-date {
  display: block;
  font-size: .75rem;
  color: var(--text-light);
  margin-top: 3px;
}

/* ── Page Hero ─────────────────────────────────────────────── */
.page-hero {
  padding: 60px 0 44px;
}
.page-hero h1 {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -.6px;
  line-height: 1.2;
  margin-bottom: 10px;
}
.page-hero p {
  color: var(--text-muted);
  font-size: .95rem;
}

/* ── Divider ───────────────────────────────────────────────── */
.section-divider {
  height: 1px;
  background: var(--border);
  margin-bottom: 8px;
}

/* ── Post List ─────────────────────────────────────────────── */
.post-list { list-style: none; }

.post-card {
  padding: 32px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  position: relative;
}
.post-card:last-child { border-bottom: none; }

.post-card::before {
  content: '';
  position: absolute;
  left: -24px; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
  opacity: 0;
  transition: opacity .2s;
}
.post-card:hover::before { opacity: 1; }
.post-card:hover .post-title { color: var(--accent); }

.post-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.post-date {
  font-size: .8rem;
  color: var(--text-light);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.post-tags { display: flex; gap: 6px; flex-wrap: wrap; }

.tag {
  display: inline-block;
  padding: 2px 10px;
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .01em;
}

.post-title {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.45;
  margin-bottom: 8px;
  color: var(--text);
  transition: color .15s;
  letter-spacing: -.2px;
}

.post-summary {
  font-size: .9rem;
  color: var(--text-muted);
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.read-more {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 14px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--accent);
}
.read-more::after {
  content: '→';
  transition: transform .15s;
}
.post-card:hover .read-more::after { transform: translateX(3px); }

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 80px 0;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 2.5rem; margin-bottom: 16px; }
.empty-state p { font-size: .95rem; }

/* ── Skeleton ──────────────────────────────────────────────── */
.skeleton {
  display: inline-block;
  height: 1em;
  border-radius: 4px;
  background: linear-gradient(90deg,
    var(--bg-alt) 25%, var(--border) 50%, var(--bg-alt) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Reading Progress Bar ──────────────────────────────────── */
.reading-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #818cf8);
  width: 0%;
  z-index: 200;
  transition: width .1s linear;
  border-radius: 0 2px 2px 0;
}

/* ── Article Page ──────────────────────────────────────────── */

/* 文章正文在两栏时限制宽度保证可读性 */
.layout-two-col .article-body {
  max-width: var(--content-w);
}

.post-header {
  padding: 52px 0 36px;
}
.post-header .post-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -.5px;
  margin-bottom: 16px;
  line-height: 1.3;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 32px;
  margin-bottom: 4px;
  font-size: .83rem;
  color: var(--text-muted);
  font-weight: 500;
  transition: color .15s;
}
.back-link:hover { color: var(--accent); text-decoration: none; }
.back-link svg { width: 15px; height: 15px; }

/* ── Article Body ──────────────────────────────────────────── */
.article-body {
  padding-bottom: 80px;
  font-size: 1.02rem;
}

.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4 {
  font-weight: 700;
  line-height: 1.35;
  margin: 2.2em 0 .8em;
  color: var(--text);
  letter-spacing: -.3px;
}
.article-body h2 {
  font-size: 1.4rem;
  padding-bottom: .5em;
  border-bottom: 1px solid var(--border);
}
.article-body h3 { font-size: 1.15rem; }
.article-body h4 { font-size: 1rem; }

.article-body p { margin-bottom: 1.3em; }
.article-body ul, .article-body ol {
  margin: .8em 0 1.3em 1.4em;
}
.article-body li { margin-bottom: .5em; }

.article-body blockquote {
  margin: 1.8em 0;
  padding: 16px 20px;
  border-left: 3px solid var(--accent);
  background: var(--accent-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-muted);
  font-style: italic;
}

/* Code block wrapper */
.code-wrapper {
  position: relative;
  margin: 1.6em 0;
}
.code-lang-label {
  position: absolute;
  top: 10px; right: 44px;
  font-size: .72rem;
  color: var(--text-light);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.copy-code-btn {
  position: absolute;
  top: 8px; right: 10px;
  padding: 3px 10px;
  background: var(--bg);
  border: 1px solid var(--code-border);
  border-radius: 6px;
  font-size: .72rem;
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--font);
  transition: all .15s;
  opacity: .8;
}
.copy-code-btn:hover { opacity: 1; background: var(--accent); color: #fff; border-color: var(--accent); }
.copy-code-btn.copied { background: #16a34a; color: #fff; border-color: #16a34a; opacity: 1; }

.article-body pre {
  padding: 20px 20px 18px;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: .875rem;
  line-height: 1.65;
}
.article-body code {
  font-family: var(--font-mono);
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: .875em;
  color: #e05c6e;
}
@media (prefers-color-scheme: dark) {
  .article-body code { color: #fb8fa4; }
}
.article-body pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
  border-radius: 0;
}

.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.6em 0;
  font-size: .9rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.article-body th, .article-body td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.article-body th {
  background: var(--bg-alt);
  font-weight: 600;
  font-size: .85rem;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.article-body tr:last-child td { border-bottom: none; }
.article-body hr { border: none; border-top: 1px solid var(--border); margin: 2.5em 0; }
.article-body img {
  border-radius: var(--radius);
  margin: 1.5em auto;
  box-shadow: var(--shadow-md);
}
.article-body a { color: var(--accent); font-weight: 500; }

/* ── Tools Page ────────────────────────────────────────────── */
.tools-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding-bottom: 60px;
}

.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s, border-color .2s;
}
.tool-card:hover {
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
}

.tool-card h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -.2px;
}
.tool-icon { font-size: 1.15rem; }

.tool-textarea, .tool-input {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: .85rem;
  line-height: 1.55;
  resize: vertical;
  background: var(--bg-alt);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.tool-textarea:focus, .tool-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}
.tool-textarea { min-height: 100px; }

.tool-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: background .15s, transform .1s, box-shadow .15s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 3px color-mix(in srgb, var(--accent) 40%, transparent);
}
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary {
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }
.btn-sm { padding: 5px 12px; font-size: .8rem; }

.tool-output {
  margin-top: 10px;
  padding: 11px 13px;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: .85rem;
  min-height: 42px;
  word-break: break-all;
  white-space: pre-wrap;
  color: var(--text);
}
.tool-output.error { color: #dc2626; background: #fef2f2; border-color: #fecaca; }

.tool-divider {
  display: flex;
  align-items: center;
  margin: 12px 0;
  gap: 10px;
  color: var(--text-light);
  font-size: .78rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.tool-divider::before, .tool-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

.ts-result { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.ts-result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  font-size: .85rem;
  gap: 8px;
  border: 1px solid var(--border);
}
.ts-result-row label {
  color: var(--text-muted);
  font-size: .78rem;
  min-width: 70px;
  font-weight: 500;
}
.ts-result-row code {
  font-family: var(--font-mono);
  color: var(--text);
  font-size: .85rem;
  flex: 1;
  background: none;
  border: none;
  padding: 0;
}

.copy-btn {
  padding: 3px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: .74rem;
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--font);
  font-weight: 500;
  transition: all .15s;
  white-space: nowrap;
}
.copy-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.copy-btn.copied { background: #16a34a; color: #fff; border-color: #16a34a; }

.wc-stats { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.wc-stat {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  text-align: center;
  flex: 1;
  min-width: 70px;
}
.wc-stat .num {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}
.wc-stat .label { font-size: .72rem; color: var(--text-muted); font-weight: 500; }

/* ── Footer ────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 24px;
  text-align: center;
}
.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.footer-copy {
  font-size: .82rem;
  color: var(--text-muted);
}
.footer-icp {
  font-size: .78rem;
  color: var(--text-light);
}
.footer-icp a {
  color: var(--text-light);
  transition: color .15s;
}
.footer-icp a:hover { color: var(--text-muted); text-decoration: none; }

/* ── Responsive ────────────────────────────────────────────── */

/* 平板：隐藏侧边栏 */
@media (max-width: 860px) {
  .layout-two-col {
    grid-template-columns: 1fr;
  }
  .layout-aside { display: none; }
  .container { padding: 0 28px; }
}

/* 手机 */
@media (max-width: 640px) {
  :root { --header-h: 56px; }

  .header-inner { padding: 0 16px; }
  .container { padding: 0 16px; }
  .site-footer { padding: 24px 16px; }

  .page-hero { padding: 40px 0 32px; }
  .page-hero h1 { font-size: 1.75rem; }

  .post-header { padding: 36px 0 28px; }
  .post-header .post-title { font-size: 1.6rem; }

  .post-card { padding: 24px 0; }
  .post-card::before { left: -16px; }
  .post-title { font-size: 1.1rem; }

  .tool-card { padding: 18px 16px; }
  .wc-stats { gap: 8px; }
  .wc-stat { padding: 10px 12px; }
}

@media (max-width: 400px) {
  .nav-link { padding: 5px 10px; font-size: .82rem; }
  .page-hero h1 { font-size: 1.5rem; }
}
