:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --fg: #1b1a17;
  --muted: #78736b;
  --border: #ede9e1;
  --accent: #f5620d;
  --accent-ink: #ffffff;
  --accent-soft: #fdeee3;
  --code-bg: #f5f2ec;
  --shadow: 0 1px 2px rgba(20, 18, 15, 0.05);
  --shadow-lg: 0 14px 34px -16px rgba(20, 18, 15, 0.28);
  --max: 700px;
  --radius: 16px;
  --font-read: 'LXGW WenKai GB Screen', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16151a;
    --surface: #201f25;
    --fg: #eceae6;
    --muted: #9e988e;
    --border: #2c2a32;
    --accent: #fb8b4c;
    --accent-ink: #1b1a17;
    --accent-soft: #2a2017;
    --code-bg: #1b1a20;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 40px -18px rgba(0, 0, 0, 0.7);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-read);
  font-size: 17px;
  line-height: 1.78;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
h1, h2, h3 { letter-spacing: -0.02em; }

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

/* ---------------- avatar ---------------- */
.avatar {
  border-radius: 50%;
  object-fit: cover;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  flex: none;
}
.avatar-emoji {
  background: var(--accent-soft);
  line-height: 1;
}
.hero .avatar { box-shadow: var(--shadow-lg); border: 3px solid var(--surface); }

/* ---------------- header / footer ---------------- */
.site-header, .admin-bar {
  max-width: var(--max);
  margin: 0 auto;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.site-header { border-bottom: 1px solid var(--border); }
/* Admin is an operating surface — use the full viewport width.
   The public site keeps the narrow reading measure above. */
.admin-bar { max-width: none; padding-left: 32px; padding-right: 32px; }
body.admin .container { max-width: none; padding: 28px 32px 80px; }
@media (max-width: 640px) {
  .admin-bar { padding-left: 18px; padding-right: 18px; }
  body.admin .container { padding-left: 18px; padding-right: 18px; }
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 17px;
  color: var(--fg);
}
.brand:hover { text-decoration: none; }
.site-header nav { margin-left: auto; display: flex; gap: 18px; font-size: 15px; }
.site-header nav a { color: var(--muted); }
.site-header nav a:hover { color: var(--accent); text-decoration: none; }
.admin-bar { border-bottom: 1px solid var(--border); }
.admin-bar nav { margin-left: auto; display: flex; gap: 18px; font-size: 14px; }
.site-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 40px 0; }
.site-footer p { margin: 4px 0; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--accent); text-decoration: none; }

/* ---------------- hero ---------------- */
.hero { text-align: center; padding: 40px 0 48px; }
.hero-title {
  font-size: clamp(28px, 6vw, 42px);
  font-weight: 800;
  margin: 22px 0 12px;
  line-height: 1.15;
}
.hero .wave { display: inline-block; transform-origin: 70% 70%; animation: wave 2.4s ease-in-out infinite; }
@keyframes wave {
  0%, 60%, 100% { transform: rotate(0deg); }
  10%, 30% { transform: rotate(14deg); }
  20% { transform: rotate(-8deg); }
  40% { transform: rotate(-4deg); }
}
.hero-tagline { color: var(--muted); font-size: 18px; margin: 0 auto; max-width: 34em; }
@media (prefers-reduced-motion: reduce) { .hero .wave { animation: none; } }

/* ---------------- post list (cards) ---------------- */
.post-list { display: flex; flex-direction: column; gap: 20px; }
.post-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  color: inherit;
}
.post-card:hover {
  text-decoration: none;
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}
.post-card .cover {
  margin: -22px -24px 18px;
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
  aspect-ratio: 16 / 8;
}
.post-card .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-card h2 { margin: 0 0 8px; font-size: 22px; font-weight: 800; }
.post-card:hover h2 { color: var(--accent); }
.post-card .excerpt { color: var(--muted); margin: 0 0 14px; }
.meta {
  color: var(--muted);
  font-size: 13.5px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.meta .dot { opacity: 0.6; }

.pager { display: flex; justify-content: space-between; margin-top: 44px; }
.empty { color: var(--muted); text-align: center; padding: 60px 0; }

/* ---------------- single post ---------------- */
.post-full h1 {
  font-size: clamp(28px, 5vw, 38px);
  font-weight: 800;
  margin: 8px 0 20px;
  line-height: 1.2;
}
.byline { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.byline-author { display: block; font-weight: 700; font-size: 15px; }
.byline-meta { display: block; color: var(--muted); font-size: 13.5px; }
.post-full .cover { border-radius: var(--radius); margin: 8px 0 28px; width: 100%; }

.content { font-size: 17.5px; line-height: 1.8; }
.content > *:first-child { margin-top: 0; }
.content h2 { font-size: 25px; margin-top: 1.9em; margin-bottom: 0.5em; }
.content h3 { font-size: 20px; margin-top: 1.6em; }
.content p, .content ul, .content ol { margin: 1.05em 0; }
.content a { text-decoration: underline; text-underline-offset: 2px; }
.content pre {
  background: var(--code-bg);
  padding: 16px 18px;
  border-radius: 12px;
  overflow-x: auto;
  font-size: 14.5px;
  line-height: 1.6;
  font-family: var(--font-mono);
}
.content code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.88em;
  font-family: var(--font-mono);
}
.content pre code { background: none; padding: 0; }
.content blockquote {
  border-left: 3px solid var(--accent);
  margin: 1.4em 0;
  padding: 2px 18px;
  color: var(--muted);
}
.content img { border-radius: 12px; }
.content table { border-collapse: collapse; width: 100%; font-size: 15px; }
.content th, .content td { border: 1px solid var(--border); padding: 8px 12px; }
.content hr { border: none; border-top: 1px solid var(--border); margin: 2.4em 0; }

.terms { margin-top: 40px; display: flex; flex-wrap: wrap; gap: 8px; }
.term {
  font-size: 13px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 600;
}
.term:hover { text-decoration: none; filter: brightness(0.97); }
.back { margin-top: 44px; }
.archive-title { font-size: 26px; font-weight: 800; margin-bottom: 28px; }

.comments { margin-top: 60px; padding-top: 28px; border-top: 1px solid var(--border); }
.comments h2 { font-size: 20px; font-weight: 800; margin: 0 0 18px; }

/* ---------------- buttons ---------------- */
.btn {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 18px;
  border-radius: 10px;
  border: none;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); filter: brightness(1.03); }
.btn.ghost {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
}
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
button.link {
  background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; font-size: 14px;
}
button.link.danger { color: #dc2626; }

/* ---------------- confirm dialog ---------------- */
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(20, 18, 15, 0.45);
}
.confirm-overlay[hidden] { display: none; } /* re-hide: our display:flex beats [hidden] */
.confirm-box {
  width: 100%;
  max-width: 360px;
  padding: 24px 22px 18px;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.confirm-msg { margin: 0 0 20px; font-size: 15px; line-height: 1.6; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 12px; }
.btn.danger-btn { background: #dc2626; color: #fff; }
body.modal-open { overflow: hidden; }

/* ---------------- forms / admin ---------------- */
.login { max-width: 340px; margin: 56px auto; display: flex; flex-direction: column; gap: 16px; }
.login h1 { font-size: 24px; font-weight: 800; margin: 0 0 4px; }
.login label, .editor-side label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
input, textarea, select, button {
  font-family: inherit;
}
input, textarea, select {
  font-size: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--fg);
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.error { color: #dc2626; font-size: 14px; }

.toolbar { display: flex; align-items: center; justify-content: space-between; }
.toolbar h1 { font-size: 26px; font-weight: 800; }
.post-table { width: 100%; border-collapse: collapse; margin-top: 16px; }
.post-table th, .post-table td {
  text-align: left;
  padding: 12px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle; /* keep every cell (incl. actions) on the row's centre line */
}
.post-table th { font-size: 13px; color: var(--muted); font-weight: 600; }
.post-dates { font-size: 13px; white-space: nowrap; line-height: 1.5; }
.post-dates .hint { font-size: 12px; }
input:disabled, input[readonly] { color: var(--muted); background: var(--code-bg); cursor: default; }
.badge { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--code-bg); }
.badge.published { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
/* The cell stays a real table cell (centred on the row); a flex row inside it
   keeps the links and the delete <button> on one baseline regardless of the
   <form> wrapper. */
.row-actions { white-space: nowrap; }
.row-actions .actions {
  display: flex;
  align-items: center;
  gap: 18px;
  line-height: 1;
}
/* Let the <form> dissolve so its <button> is a direct flex child of .actions,
   sitting on the exact same centre line as the 编辑/查看 links. */
.row-actions .actions form { display: contents; }
.row-actions a,
.row-actions button.link {
  /* Pin the typeface explicitly: a <button> and an <a> can otherwise render
     with subtly different fonts/metrics, so "删除" looks off next to the links. */
  font-family: var(--font-read);
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
}

/* editor */
.editor { display: grid; grid-template-columns: 1fr 288px; gap: 24px; align-items: start; }
.editor-main { min-width: 0; } /* let the editor shrink instead of overflowing the grid */
.title-input { font-size: 24px; font-weight: 700; margin-bottom: 14px; }
/* wangEditor rich-text editor */
.wang-wrap { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: #fff; }
#toolbar-container { border-bottom: 1px solid var(--border); }
#editor-container { height: calc(100vh - 260px); min-height: 420px; overflow-y: auto; }
.w-e-text-container [data-slate-editor] { font-family: var(--font-read); }
.w-e-text-container [data-slate-editor] pre,
.w-e-text-container [data-slate-editor] code { font-family: var(--font-mono); }
.editor-side { display: flex; flex-direction: column; gap: 16px; }
.editor-actions { display: flex; gap: 10px; }
.hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; line-height: 1.5; }

@media (max-width: 820px) {
  .editor { grid-template-columns: 1fr; }
}

/* settings */
.notice {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
}
.settings { max-width: 640px; display: flex; flex-direction: column; gap: 32px; }
.settings-group { display: flex; flex-direction: column; gap: 16px; }
.settings-group > h2 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ---------------- category filter (public) ---------------- */
.cat-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0 28px;
}
.cat-filter .chip {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 14px;
  color: var(--fg);
  background: var(--surface);
  transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}
.cat-filter .chip:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.cat-filter .chip.active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

/* ---------------- category picker (editor) ---------------- */
.cat-picker { display: flex; flex-direction: column; gap: 8px; }
.cat-picker-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 14px;
  color: var(--muted);
}
.cat-picker-head a { font-size: 13px; }
.cat-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.cat-option {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--fg);
  cursor: pointer;
}
.cat-option input { width: auto; margin: 0; }

/* ---------------- category management (admin) ---------------- */
.cat-new { display: flex; gap: 12px; margin: 16px 0; max-width: 420px; }
.cat-new input { flex: 1; }
.cat-rename { display: flex; align-items: center; gap: 10px; }
.cat-rename input { width: auto; min-width: 0; flex: 1; max-width: 220px; }

/* ---------------- about page ---------------- */
.about-page .about-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.about-page .about-head h1 { margin: 0; }
