/* 博客：公开列表/文章 + 编辑后台，延续暖白 + 墨绿 */
:root {
  --bg: #f4f2ea;
  --card: #fffdf8;
  --card-2: #fbf9f2;
  --ink: #263238;
  --muted: #6b7780;
  --line: #ddd8cb;
  --green: #1f6f5c;
  --green-deep: #155445;
  --green-soft: #e4efe9;
  --amber: #b7791f;
  --amber-soft: #f6ecd9;
  --red: #b23b3b;
  --red-soft: #f8eaea;
  --shadow: 0 18px 45px rgba(32, 44, 39, 0.08);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121816;
    --card: #1b2421;
    --card-2: #202b27;
    --ink: #e8ecea;
    --muted: #98a6a0;
    --line: #2c3934;
    --green: #79c9ab;
    --green-deep: #a5dfc8;
    --green-soft: #223430;
    --amber: #e0b36a;
    --amber-soft: #332b1f;
    --red: #e08585;
    --red-soft: #33201f;
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font: 15px/1.75 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

.glow {
  position: fixed;
  z-index: 0;
  width: 620px;
  height: 620px;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.45;
  pointer-events: none;
}
.glow-a { top: -260px; left: -180px; background: var(--green-soft); }

.page {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 22px 40px;
}

.page-wide { max-width: 1320px; }

/* ------------------------------------------------------------- 顶部 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--green), var(--green-deep));
  color: #fff;
  font-size: 19px;
  font-weight: 700;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-text b { font-size: 16px; }
.brand-text small { font-size: 11.5px; color: var(--muted); }

.top-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
}
.top-nav a { color: var(--muted); }
.top-nav a:hover { color: var(--ink); text-decoration: none; }

/* ------------------------------------------------------------- 通用 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 15px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: border-color .15s, filter .15s, opacity .15s;
}
.btn:hover { border-color: var(--green); text-decoration: none; }
.btn.primary { background: var(--green); border-color: transparent; color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { background: var(--red-soft); border-color: transparent; color: var(--red); }
.btn.small { padding: 7px 11px; font-size: 12px; }
.btn.subtle { background: transparent; color: var(--muted); }
.btn:disabled { opacity: .55; cursor: default; }

.search {
  width: 100%;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  outline: none;
}
.search:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }

/* ------------------------------------------------------------- 列表页 */
.hero { padding: 54px 0 30px; max-width: 680px; }
.eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--green);
}
.hero h1 { margin: 0 0 12px; font-size: clamp(32px, 5.5vw, 48px); line-height: 1.15; letter-spacing: -0.02em; }
.hero .sub { margin: 0; color: var(--muted); font-size: 15px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.search-form {
  display: flex;
  gap: 8px;
  flex: 1 1 320px;
  min-width: 0;
}

.tag-list { display: flex; flex-wrap: wrap; gap: 7px; }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-size: 12px;
}
.tag:hover { border-color: var(--green); color: var(--green); text-decoration: none; }
.tag.is-active { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.tag .n { margin-left: 5px; opacity: .7; }

.result-meta { margin: 0 0 14px; font-size: 12px; color: var(--muted); }

.post-list { display: flex; flex-direction: column; gap: 12px; }

.post-card {
  display: block;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.post-card:hover {
  text-decoration: none;
  border-color: var(--green);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.post-meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.post-card h2 { margin: 0 0 6px; font-size: 21px; line-height: 1.35; }
.post-card p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.post-card .tag-list { gap: 6px; }

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  border: 1px dashed var(--line);
  border-radius: 16px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
}

/* ------------------------------------------------------------- 文章页 */
.article { max-width: 760px; margin: 0 auto; padding-top: 42px; }
.article-head { margin-bottom: 28px; }
.article-head h1 { margin: 0 0 10px; font-size: clamp(30px, 5vw, 42px); line-height: 1.2; letter-spacing: -0.02em; }
.article-meta { margin: 0 0 12px; font-size: 12px; color: var(--muted); }

.article-body { font-size: 16px; line-height: 1.85; }
.article-body > *:first-child { margin-top: 0; }
.article-body h1, .article-body h2, .article-body h3, .article-body h4 {
  margin: 1.6em 0 0.6em;
  line-height: 1.35;
  letter-spacing: -0.01em;
}
.article-body h2 { font-size: 24px; }
.article-body h3 { font-size: 19px; }
.article-body h4 { font-size: 16px; }
.article-body p { margin: 0 0 1.1em; }
.article-body ul, .article-body ol { margin: 0 0 1.1em; padding-left: 1.4em; }
.article-body li { margin: 0.25em 0; }
.article-body blockquote {
  margin: 1.2em 0;
  padding: 10px 18px;
  border-left: 3px solid var(--green);
  background: var(--card-2);
  border-radius: 0 10px 10px 0;
  color: var(--muted);
}
.article-body blockquote p:last-child { margin-bottom: 0; }
.article-body code {
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--card-2);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.88em;
}
.article-body pre {
  margin: 1.2em 0;
  padding: 14px 16px;
  overflow-x: auto;
  border-radius: 12px;
  background: var(--card-2);
  border: 1px solid var(--line);
}
.article-body pre code { padding: 0; border: 0; background: transparent; font-size: 13px; }
.article-body img { max-width: 100%; height: auto; border-radius: 12px; }
.article-body hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.article-body a { text-decoration: underline; text-underline-offset: 3px; }

.md-table-wrap { overflow-x: auto; margin: 1.2em 0; }
.md-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.md-table th, .md-table td { border: 1px solid var(--line); padding: 8px 11px; text-align: left; }
.md-table th { background: var(--green-soft); color: var(--green); font-weight: 600; }

.article-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

/* ------------------------------------------------------------- 后台 */
.editor-body { background: var(--bg); }
.editor-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  margin-top: 20px;
  align-items: start;
}

.post-side {
  position: sticky;
  top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.side-head { display: flex; align-items: center; justify-content: space-between; }
.side-head h2 { margin: 0; font-size: 15px; }

.post-side .post-list { overflow-y: auto; gap: 6px; padding-right: 4px; }

.post-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card-2);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.post-item:hover { border-color: var(--green); }
.post-item.is-active { border-color: var(--green); background: var(--green-soft); }
.post-item b { display: block; font-size: 13px; line-height: 1.45; }
.post-item small { display: block; margin-top: 3px; font-size: 11px; color: var(--muted); }

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  background: var(--card-2);
  color: var(--muted);
  border: 1px solid var(--line);
}
.badge.published { background: var(--green-soft); color: var(--green); border-color: transparent; }

.editor-main {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
}

.editor-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.title-input {
  flex: 1;
  min-width: 0;
  padding: 10px 2px;
  font: inherit;
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  outline: none;
}
.title-input:focus { border-color: var(--green); }

.status { font-size: 12px; color: var(--muted); white-space: nowrap; }
.status.is-ok { color: var(--green); }
.status.is-error { color: var(--red); }

.meta-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 12px; margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 11.5px; color: var(--muted); }

.meta-grid input, .meta-grid select, .summary-input {
  width: 100%;
  padding: 9px 11px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  font: inherit;
  font-size: 13px;
  outline: none;
}
.meta-grid input:focus, .meta-grid select:focus, .summary-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.summary-input { margin-bottom: 12px; }

.editor-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}

.writing { display: flex; flex-direction: column; min-width: 0; }

.md-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  background: var(--card-2);
}
.md-toolbar button {
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.md-toolbar button:hover { background: var(--green-soft); color: var(--green); }

#content {
  flex: 1;
  min-height: 420px;
  padding: 13px 14px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 0 0 10px 10px;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.75;
  resize: vertical;
  outline: none;
}
#content:focus { border-color: var(--green); }

.preview {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  overflow: hidden;
}
.preview-head {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--card-2);
  font-size: 12px;
  color: var(--muted);
}
.preview-body {
  flex: 1;
  padding: 14px 16px;
  overflow-y: auto;
  max-height: 640px;
  font-size: 14px;
}
.preview-empty { color: var(--muted); }

.editor-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}
.editor-actions .spacer { flex: 1; }

.hint { margin: 10px 0 0; font-size: 11.5px; color: var(--muted); }

/* ------------------------------------------------------------- 页脚 */
.footer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 48px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.footer a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.footer .dot { opacity: .6; }

/* ------------------------------------------------------------- 响应式 */
@media (max-width: 900px) {
  .editor-layout { grid-template-columns: 1fr; }
  .post-side { position: static; max-height: none; }
  .post-side .post-list { max-height: 32vh; }
  .editor-split { grid-template-columns: 1fr; }
  #content { min-height: 320px; }
  .preview-body { max-height: 360px; }
}

@media (max-width: 680px) {
  .page { padding: 18px 15px 30px; }
  .top-nav { gap: 12px; }
  .hero { padding: 40px 0 24px; }
  .post-card { padding: 18px; }
  .post-card h2 { font-size: 18px; }
  .meta-grid { grid-template-columns: 1fr; }
  .editor-main { padding: 15px; }
  .title-input { font-size: 20px; }
  .article { padding-top: 30px; }
  .article-foot { flex-direction: column-reverse; }
  .article-foot .btn { width: 100%; }
}

@media (max-width: 420px) {
  .brand-text small { display: none; }
  .top-nav a:not(:last-child) { display: none; }
}
