:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e6ea;
  --text: #1e2430;
  --text-dim: #626b7a;
  --text-mute: #8a929f;
  --accent: #2f6f4f;
  --accent-soft: #e7f1eb;
  --items: #2f6f4f;
  --commits: #3d6b9c;
  --releases: #b3752c;
  --radius: 6px;
  --wrap: 1080px;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, "Courier New", monospace;
}

[data-theme="dark"] {
  --bg: #14171c;
  --surface: #1b1f26;
  --border: #2b313b;
  --text: #e6e9ee;
  --text-dim: #a3acba;
  --text-mute: #7b8494;
  --accent: #5fae86;
  --accent-soft: #1f2b25;
  --items: #5fae86;
  --commits: #6f9fd0;
  --releases: #d09a56;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 15px;
  line-height: 1.7;
  letter-spacing: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main { flex: 1; }

a { color: inherit; text-decoration: none; }

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

/* 头部 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 58px;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand-mark {
  width: 10px;
  height: 22px;
  border-radius: 2px;
  background: linear-gradient(var(--items) 34%, var(--commits) 34% 67%, var(--releases) 67%);
  flex: none;
}

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 15px; line-height: 1.3; }
.brand-text small { color: var(--text-mute); font-size: 12px; line-height: 1.3; }

.nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }

.nav a {
  padding: 5px 10px;
  border-radius: 4px;
  color: var(--text-dim);
  font-size: 14px;
}

.nav a:hover { background: var(--accent-soft); color: var(--accent); }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}

.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

.main { padding: 28px 0 56px; }

/* 面板 */
.dash-head { margin-bottom: 20px; }
.dash-head h1 { margin: 0; font-size: 22px; }
.dash-sub { margin: 4px 0 0; color: var(--text-dim); font-size: 14px; }

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-left: 3px solid var(--accent);
  padding: 12px 14px;
  min-height: 76px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.metric.tone-b { border-left-color: var(--items); }
.metric.tone-c { border-left-color: var(--commits); }
.metric.tone-d { border-left-color: var(--releases); }
.metric.tone-e { border-left-color: var(--text-mute); }

.metric-label { color: var(--text-mute); font-size: 12px; }

.metric-value {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.2;
}

.metric-value em {
  font-family: inherit;
  font-size: 12px;
  font-style: normal;
  font-weight: 400;
  color: var(--text-mute);
  margin-left: 4px;
}

/* 通用面板容器 */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h2 { margin: 0; font-size: 15px; }

.legend { display: flex; align-items: center; gap: 12px; color: var(--text-mute); font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 4px; }
.dot-items { background: var(--items); }
.dot-commits { background: var(--commits); }
.dot-releases { background: var(--releases); }

/* 柱状图 */
.chart {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-items: end;
  gap: 10px;
  height: 168px;
  padding-top: 8px;
}

.chart-col { display: flex; flex-direction: column; height: 100%; min-width: 0; }

.bars {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  min-height: 0;
}

.bar {
  width: 9px;
  min-height: 2px;
  border-radius: 2px 2px 0 0;
  transition: opacity .15s;
}

.bar:hover { opacity: .7; }
.bar-items { background: var(--items); }
.bar-commits { background: var(--commits); }
.bar-releases { background: var(--releases); }

.chart-x {
  margin-top: 8px;
  text-align: center;
  color: var(--text-mute);
  font-family: var(--mono);
  font-size: 11px;
}

/* 面板双栏 */
.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.week-list, .mod-list, .entry-list { list-style: none; margin: 0; padding: 0; }

.week-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--border);
}

.week-list li:last-child { border-bottom: 0; }
.week-link { display: flex; flex-direction: column; min-width: 0; }
.week-id { font-family: var(--mono); font-size: 14px; }
.week-link:hover .week-id { color: var(--accent); }
.week-range { color: var(--text-mute); font-size: 12px; }

.week-stats { color: var(--text-dim); font-size: 12px; white-space: nowrap; flex: none; }
.week-stats b { font-family: var(--mono); font-weight: 600; color: var(--text); margin: 0 2px 0 8px; }

.mod-list li {
  display: grid;
  grid-template-columns: minmax(64px, 104px) 1fr 28px;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}

.mod-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mod-bar { height: 7px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.mod-bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

.mod-count { font-family: var(--mono); font-size: 12px; color: var(--text-dim); text-align: right; }

.empty { color: var(--text-mute); font-size: 13px; padding: 8px 0; }

/* 文章 */
.post-head { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.post-kicker { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--text-mute); font-size: 12px; }
.post-head h1 { margin: 8px 0 0; font-size: 21px; line-height: 1.4; }

.tag-kind { padding: 1px 7px; border-radius: 3px; font-size: 11px; }
.kind-weekly { background: var(--accent-soft); color: var(--accent); }
.kind-log { background: var(--bg); color: var(--text-dim); border: 1px solid var(--border); }
.tag-proj { font-family: var(--mono); color: var(--text-dim); }

.post-stats { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; color: var(--text-dim); font-size: 12px; }
.post-stats b { font-family: var(--mono); font-size: 16px; font-weight: 600; color: var(--text); margin-right: 3px; }

.post-layout { display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 32px; align-items: start; }

.post-body { min-width: 0; }
.post-body h2 { margin: 28px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); font-size: 17px; }
.post-body h3 { margin: 20px 0 8px; font-size: 15px; }
.post-body h3 a { color: var(--accent); }
.post-body p, .post-body li { color: var(--text); }
.post-body ul { padding-left: 20px; }
.post-body li { margin: 3px 0; }
.post-body strong { font-weight: 600; }
.post-body hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }
.post-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

.post-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 13.5px;
  display: block;
  overflow-x: auto;
}

.post-body th, .post-body td { padding: 7px 10px; border: 1px solid var(--border); text-align: left; vertical-align: top; }
.post-body th { background: var(--bg); font-weight: 600; white-space: nowrap; }
.post-body tbody tr:hover { background: var(--accent-soft); }

.post-body code {
  font-family: var(--mono);
  font-size: .88em;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
}

.post-body pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  overflow-x: auto;
}

.post-body pre code { background: none; border: 0; padding: 0; }

.post-body blockquote {
  margin: 14px 0;
  padding: 2px 14px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-dim);
}

/* 目录 */
.post-toc { position: sticky; top: 78px; max-height: calc(100vh - 110px); overflow-y: auto; font-size: 13px; }
.toc-title { margin: 0 0 6px; color: var(--text-mute); font-size: 12px; }
.post-toc ol { list-style: none; margin: 0; padding-left: 12px; border-left: 1px solid var(--border); }
.post-toc > ol { padding-left: 0; border-left: 0; }
.post-toc a { display: block; padding: 3px 0; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-toc a:hover, .post-toc .active > a { color: var(--accent); }

.post-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 28px; }
.post-tags a { padding: 3px 9px; border: 1px solid var(--border); border-radius: 3px; color: var(--text-dim); font-size: 12px; }
.post-tags a:hover { border-color: var(--accent); color: var(--accent); }

.post-nav { display: flex; justify-content: space-between; gap: 16px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 13px; }
.post-nav a { color: var(--text-dim); max-width: 46%; }
.post-nav a:hover { color: var(--accent); }
.nav-next { margin-left: auto; text-align: right; }

/* 列表页 */
.listing-head { margin-bottom: 16px; }
.listing-head h1 { margin: 0; font-size: 20px; }
.listing-count { margin: 4px 0 0; color: var(--text-mute); font-size: 13px; }

.entry {
  display: flex;
  gap: 14px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.entry > time { font-family: var(--mono); font-size: 12px; color: var(--text-mute); padding-top: 2px; flex: none; }
.entry-main { min-width: 0; }
.entry-title { font-size: 15px; }
.entry-title:hover { color: var(--accent); }
.entry-meta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; color: var(--text-mute); font-size: 12px; }

.pager { display: flex; justify-content: center; gap: 8px; margin-top: 20px; font-size: 13px; }
.pager a, .pager .page-number { padding: 4px 9px; border: 1px solid var(--border); border-radius: 4px; color: var(--text-dim); }
.pager .current { background: var(--accent); border-color: var(--accent); color: #fff; }

/* 页脚 */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 18px 0; color: var(--text-mute); font-size: 12px; margin-top: auto; }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* 响应式 */
@media (max-width: 900px) {
  .post-layout { grid-template-columns: 1fr; }
  .post-toc { display: none; }
  .dash-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .header-inner { height: auto; padding: 10px 20px; flex-wrap: wrap; }
  .nav { width: 100%; margin-left: 0; order: 3; }
  .theme-toggle { margin-left: auto; }
  .metrics { grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); }
  .metric-value { font-size: 20px; }
  .chart { height: 140px; gap: 6px; }
  .bar { width: 7px; }
  .week-list li { flex-direction: column; align-items: flex-start; gap: 3px; }
  .week-stats b { margin-left: 0; }
}
