:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --ink: #243038;
  --muted: #6b7a85;
  --line: #e3e8ec;
  --accent: #3d6b7a;
  --accent-soft: #e8f1f2;
  --danger: #b8504b;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; max-width: 100%; overflow-x: hidden; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.35; font-weight: 600; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
p { margin: 0 0 .8em; }
img, svg { max-width: 100%; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar-inner {
  max-width: 920px; margin: 0 auto; padding: 12px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { font-weight: 650; color: var(--ink); font-size: 1rem; white-space: nowrap; }
.brand:hover { text-decoration: none; color: var(--accent); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a {
  padding: 6px 12px; border-radius: 8px; color: var(--muted); font-size: .92rem; white-space: nowrap;
}
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.nav-admin { opacity: .65; font-size: .9em; }

.wrap { max-width: 920px; margin: 0 auto; padding: 26px 18px 60px; }
.hero {
  background: linear-gradient(135deg, var(--accent-soft), #ffffff);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 40px 28px; margin-bottom: 26px; text-align: center;
}
.hero-title { font-size: 1.95rem; margin: 0 0 .45em; color: var(--ink); letter-spacing: .5px; }
.hero-intro { color: var(--muted); font-size: 1.02rem; max-width: 640px; margin: 0 auto; line-height: 1.85; }
.section { margin-bottom: 26px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.section-head h2 { margin: 0; padding-left: 11px; border-left: 3px solid var(--accent); line-height: 1.35; }
.section-head a { font-size: .9rem; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px;
  transition: box-shadow .2s ease, border-color .2s ease;
}
.card:hover { box-shadow: 0 6px 20px rgba(36, 48, 56, .08); border-color: #d7dee2; }
.card + .card { margin-top: 10px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.card-title { font-weight: 600; margin-bottom: 4px; }
.meta { color: var(--muted); font-size: .85rem; }
.excerpt {
  color: var(--muted); font-size: .92rem; margin-top: 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* 正文（Markdown 渲染结果）。不用 pre-wrap：换行已由 <br> / <p> 表达。 */
.post-body { white-space: normal; word-break: break-word; }
.post-body p { margin: 0 0 .85em; }
.post-body h1, .post-body h2, .post-body h3,
.post-body h4, .post-body h5, .post-body h6 { margin: 1.3em 0 .55em; line-height: 1.35; font-weight: 650; }
.post-body h1 { font-size: 1.45rem; }
.post-body h2 { font-size: 1.25rem; }
.post-body h3 { font-size: 1.08rem; }
.post-body h4, .post-body h5, .post-body h6 { font-size: 1rem; }
.post-body > :first-child { margin-top: 0; }
.post-body ul, .post-body ol { margin: 0 0 .85em; padding-left: 1.45em; }
.post-body li { margin: .2em 0; }
.post-body blockquote {
  margin: 0 0 .85em; padding: 8px 14px; border-left: 3px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 8px 8px 0; color: var(--muted);
}
.post-body blockquote p:last-child { margin-bottom: 0; }
.post-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88em; background: var(--bg); border: 1px solid var(--line);
  border-radius: 5px; padding: .1em .38em;
}
.post-body pre.post-code {
  margin: 0 0 .85em; padding: 12px 14px; overflow-x: auto;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
.post-body pre.post-code code { background: none; border: 0; padding: 0; font-size: .86rem; }
.post-body hr { border: 0; border-top: 1px solid var(--line); margin: 1.3em 0; }
.post-body del { color: var(--muted); }
.post-body a { text-decoration: underline; text-underline-offset: 2px; }
.post-body img { display: block; max-width: 100%; height: auto; margin: 14px 0; border-radius: 10px; border: 1px solid var(--line); }

/* 后台编辑器：工具栏 / 表情面板 / 预览 */
.editor-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.editor-hint { color: var(--muted); font-size: .82rem; }
#post-content { min-height: 280px; }
.emoji-wrap { position: relative; }
.emoji-panel {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0;
  width: min(340px, 88vw); padding: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(36, 48, 56, .14);
}
.emoji-cats { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.emoji-cat {
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: 3px 10px; font: inherit; font-size: .8rem; cursor: pointer;
}
.emoji-cat:hover { border-color: var(--accent); color: var(--accent); }
.emoji-cat.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.emoji-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
  gap: 4px; max-height: 210px; overflow-y: auto;
}
.emoji-btn {
  border: 1px solid transparent; background: none; border-radius: 6px;
  font-size: 1.15rem; line-height: 1; padding: 6px 0; cursor: pointer;
}
.emoji-btn:hover { background: var(--accent-soft); border-color: var(--line); }
.post-preview {
  margin-top: 10px; padding: 14px 16px;
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius);
}
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 18px; text-align: center; }

/* 标签 */
.tagbar { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 16px; }
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 11px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); font-size: .84rem; line-height: 1.6;
}
.tag:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.tag.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.tag-count { opacity: .7; font-size: .78rem; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* 图片 */
.image-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.image-card { padding: 10px; }
.image-thumb {
  width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: var(--bg);
  border-radius: 8px; display: block;
}
.image-name { font-size: .9rem; margin-top: 8px; word-break: break-all; }
.image-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

/* 视频与正文里的网络媒体 */
.post-body video {
  display: block; width: 100%; max-width: 100%; height: auto;
  margin: 14px 0; border-radius: 10px; border: 1px solid var(--line); background: #000;
}
.video-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.video-card { padding: 10px; }
.video-thumb { width: 100%; aspect-ratio: 16 / 9; display: block; border-radius: 8px; background: #000; }
.video-name { font-size: .9rem; margin-top: 8px; word-break: break-all; }
.video-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 7px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-size: .9rem; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #315968; color: #fff; }
.btn-danger { color: var(--danger); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.like-btn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 34px; padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); font: inherit; font-size: .88rem; cursor: pointer;
}
.like-btn:hover { border-color: var(--accent); color: var(--accent); }
.like-btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.like-btn .heart { font-size: 1rem; line-height: 1; }
.like-row { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); font-size: .92rem; }
th { color: var(--muted); font-weight: 600; background: #fbfcfc; }
tr:last-child td { border-bottom: 0; }
td.name { word-break: break-all; }

.h5-card { display: flex; flex-direction: column; gap: 10px; }
.h5-thumb {
  height: 92px; border-radius: 8px; background: linear-gradient(135deg, var(--accent-soft), #dbe9e4);
  display: flex; align-items: center; justify-content: center; color: var(--accent); font-size: 1.6rem;
}
.h5-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: auto; }

.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 20px; border-top: 1px solid var(--line); }

/* 管理后台 */
.admin-layout { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 20px; }
.admin-side { display: flex; flex-direction: column; gap: 4px; }
.admin-side a { padding: 8px 12px; border-radius: 8px; color: var(--muted); }
.admin-side a.active, .admin-side a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.admin-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: .88rem; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=password], textarea, select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; font-size: .94rem; background: #fff; color: var(--ink);
}
textarea { min-height: 120px; resize: vertical; }
input[type=file] { width: 100%; font-size: .9rem; }
.inline-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-row input[type=text] { flex: 1 1 200px; width: auto; min-width: 0; }
.stat-row { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); }
.stat-row b { color: var(--ink); font-size: 1.3rem; display: block; }
.msg { font-size: .9rem; margin-top: 10px; min-height: 1.2em; }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--accent); }
.link-box { font-size: .85rem; word-break: break-all; background: var(--bg); padding: 8px 10px; border-radius: 8px; margin-top: 8px; }

@media (max-width: 640px) {
  .topbar-inner { flex-direction: column; align-items: flex-start; gap: 8px; padding: 10px 14px; }
  .nav { width: 100%; }
  .nav a { padding: 6px 10px; }
  .wrap { padding: 18px 14px 44px; }
  .grid, .grid-3, .admin-layout, .image-grid, .video-grid { grid-template-columns: 1fr; }
  .admin-side { flex-direction: row; flex-wrap: wrap; }
  .admin-side a { padding: 6px 10px; }
  table, thead, tbody, tr, th, td { display: block; }
  thead { display: none; }
  tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  td { border: 0; padding: 4px 10px; }
  td::before { content: attr(data-label) ": "; color: var(--muted); font-size: .8rem; }
  .btn, .like-btn { min-height: 40px; }
}
