:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --fg: #f8fafc;
  --muted: #94a3b8;
  --accent: #fb923c;
  --accent-2: #f97316;
  --line: #334155;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
[data-theme="light"] {
  --bg: #ffffff;
  --surface: #f8fafc;
  --surface-2: #e2e8f0;
  --fg: #0f172a;
  --muted: #64748b;
  --accent: #ea580c;
  --accent-2: #c2410c;
  --line: #e2e8f0;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font: 16px/1.7 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--fg);
  background: var(--bg);
  transition: background 0.2s, color 0.2s;
}
a { color: var(--accent); text-decoration: none; }
.container { max-width: 780px; margin: 0 auto; padding: 0 24px; }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
[data-theme="light"] .site-header { background: rgba(255, 255, 255, 0.85); }
.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 64px;
}
.brand { font-weight: 700; font-size: 20px; color: var(--fg); }
.nav { display: flex; align-items: center; gap: 24px; }
.nav a { color: var(--muted); font-size: 15px; font-weight: 500; }
.nav a:hover { color: var(--fg); }
.nav a.active { color: var(--fg); }
.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--fg); }

/* Hero */
.hero { padding: 56px 0 32px; }
.hero h1 { font-size: 48px; margin: 0 0 12px; letter-spacing: -1px; }
.hero p { color: var(--muted); font-size: 18px; margin: 0; max-width: 480px; }

/* Section title */
.section-title {
  font-size: 22px;
  margin: 32px 0 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
}

/* Post list — 手风琴卡片 */
.post-list { display: flex; flex-direction: column; gap: 14px; }
.post-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
  scroll-margin-top: 84px;
}
.post-card:hover { border-color: var(--accent); }
.post-card-head {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 18px;
  background: none;
  border: none;
  text-align: left;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.thumb {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.post-body { flex: 1; min-width: 0; }
.post-body h3 {
  margin: 0 0 6px;
  font-size: 18px;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.post-meta {
  color: var(--muted);
  font-size: 13px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.post-meta .excerpt {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}
.post-stat {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.chev {
  color: var(--muted);
  margin-left: 4px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
.post-card-head[aria-expanded="true"] .chev { transform: rotate(180deg); }
.post-detail {
  border-top: 1px solid var(--line);
  padding: 8px 32px 28px;
}
.detail-loading { color: var(--muted); padding: 8px 0; }
.empty { color: var(--muted); padding: 40px 0; }

/* Pagination — 列表下方一行分页导航 */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 28px 0 8px;
}
.pager button {
  min-width: 38px;
  height: 38px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.pager button:hover:not(:disabled):not(.current) {
  border-color: var(--accent);
  color: var(--accent);
}
.pager button.current {
  background: var(--accent);
  border-color: var(--accent);
  color: #0f172a;
  font-weight: 700;
}
.pager button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.pager-dots {
  color: var(--muted);
  padding: 0 2px;
  user-select: none;
}
.pager-info {
  color: var(--muted);
  font-size: 13px;
  margin-left: 8px;
  white-space: nowrap;
}

/* 正文排版（阅读区与内联展开共用） */
.content { font-size: 17px; line-height: 1.8; }
.content h1,
.content h2,
.content h3 { margin-top: 32px; margin-bottom: 14px; }
.content p { margin: 0 0 18px; }
.content pre {
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 16px;
  border-radius: 10px;
  overflow: auto;
}
.content code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 14px;
}
.content pre code { background: none; padding: 0; border: none; }
.content blockquote {
  border-left: 3px solid var(--accent);
  margin: 0;
  padding: 6px 20px;
  color: var(--muted);
}
.content ul,
.content ol { padding-left: 24px; margin-bottom: 18px; }
.content a { border-bottom: 1px solid var(--accent); }
.content a:hover { color: var(--accent-2); }
.content img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  margin: 8px 0 18px;
  display: block;
}

/* Admin / 修改密码 共用表单样式 */
.admin-form { max-width: 760px; margin: 32px auto; }
.admin-form input[type="text"],
.admin-form input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--fg);
  font-size: 15px;
}
.admin-form textarea {
  width: 100%;
  height: 360px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--fg);
  font: 15px/1.7 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: vertical;
}
.admin-form .row { display: flex; gap: 12px; margin-top: 14px; }
.admin-form .row input { flex: 1; margin-bottom: 0; }
.admin-form button {
  background: var(--accent);
  color: #0f172a;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  padding: 12px 28px;
  font-size: 15px;
  cursor: pointer;
}
.admin-form button:hover { background: var(--accent-2); }
.msg { min-height: 22px; margin-top: 12px; font-size: 14px; }
.msg.ok { color: #4ade80; }
.msg.err { color: #f87171; }

/* Manage Posts 列表 */
.manage-list { margin-top: 24px; }
.manage-list .post-card {
  display: block;
  padding: 0;
  cursor: default;
}
.manage-list .post-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
}
.manage-list .post-card:hover { transform: none; border-color: var(--line); }
.manage-list .post-body { flex: 1; min-width: 0; }
.manage-list .post-body h3 { margin: 0 0 4px; }
.post-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}
.post-actions button {
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: border-color 0.15s, color 0.15s;
}
.post-actions button.edit { color: var(--accent); }
.post-actions button.edit:hover { border-color: var(--accent); }
.post-actions button.del { color: #f87171; }
.post-actions button.del:hover { border-color: #f87171; }
/* 编辑/删除进行中：禁用其它卡片的编辑与删除按钮 */
.manage-list.locked .post-actions button {
  opacity: 0.4;
  pointer-events: none;
  cursor: default;
}

/* 评论管理：每条笔记下方嵌套展示评论，明显区别于笔记本身 */
.manage-list .post-comments {
  margin: 0 18px 16px 74px;
  padding: 10px 14px;
  border-left: 3px solid var(--accent);
  background: var(--surface-2);
  border-radius: 0 12px 12px 0;
}
.manage-list .post-comments .comments-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
}
.manage-list .post-comments .comments-header svg { color: var(--accent); }
.comment-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.comment-row:first-of-type { border-top: none; }
.comment-main { flex: 1; min-width: 0; }
.comment-text {
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.comment-meta { margin-top: 4px; color: var(--muted); font-size: 12px; }
.comment-actions { display: flex; gap: 6px; flex-shrink: 0; }
.comment-actions button {
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: border-color 0.15s, color 0.15s;
}
.comment-actions button.edit { color: var(--accent); }
.comment-actions button.edit:hover { border-color: var(--accent); }
.comment-actions button.del { color: #f87171; }
.comment-actions button.del:hover { border-color: #f87171; }
.comment-empty { color: var(--muted); font-size: 13px; padding: 2px 0 4px; }

/* 编辑面板（管理页内联编辑） */
.edit-panel {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 22px;
  margin: 4px 0 28px;
}
.edit-panel-title { margin: 0 0 16px; font-size: 18px; color: var(--accent); }
.edit-panel input[type="text"],
.edit-panel input[type="password"],
.edit-panel textarea {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--fg);
  font-size: 15px;
}
.edit-panel textarea {
  height: 320px;
  font: 15px/1.7 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: vertical;
}
.edit-panel .row { display: flex; gap: 12px; margin-top: 14px; }
.edit-panel .row button { margin: 0; }
.edit-panel button {
  background: var(--accent);
  color: #0f172a;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  padding: 12px 28px;
  font-size: 15px;
  cursor: pointer;
}
.edit-panel button:hover { background: var(--accent-2); }
.edit-panel button#cancel-edit,
.edit-panel button#cancel-delete {
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
}
.edit-panel button#cancel-edit:hover,
.edit-panel button#cancel-delete:hover { border-color: var(--muted); }
.edit-panel button.danger { background: #ef4444; color: #fff; }
.edit-panel button.danger:hover { background: #dc2626; }
.edit-panel button#cancel-export {
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
}
.edit-panel button#cancel-export:hover { border-color: var(--muted); }
.panel-hint { color: var(--muted); font-size: 14px; margin: 0 0 14px; line-height: 1.6; }

/* 管理页顶部操作区（导出按钮） */
.section-actions { margin-top: 14px; }
.ghost-btn {
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 10px;
  padding: 9px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.ghost-btn:hover { background: var(--accent); color: #0f172a; }
.ghost-btn:disabled { opacity: 0.4; pointer-events: none; cursor: default; }

/* 删除确认面板 */
.del-meta { margin: 0 0 10px; }
.del-title { font-size: 18px; font-weight: 700; color: var(--accent); }
.del-content {
  max-height: 340px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin: 0 0 16px;
  font: 15px/1.7 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--fg);
}

@media (max-width: 600px) {
  .container { padding: 0 16px; }
  .site-header .header-inner { height: 56px; }
  .brand { font-size: 18px; }
  .nav { gap: 14px; }
  .nav a { font-size: 14px; }

  .hero { padding: 36px 0 24px; }
  .hero h1 { font-size: 34px; }
  .hero p { font-size: 16px; }
  .section-title { font-size: 20px; }

  .post-card-head { padding: 14px; gap: 12px; }
  .thumb { width: 44px; height: 44px; }
  .post-detail { padding: 8px 18px 22px; }
  .post-meta .excerpt { display: none; }

  /* 管理列表：窄屏下标题与操作按钮换行，避免挤压 */
  .manage-list .post-row { flex-wrap: wrap; padding: 12px 14px; }
  .manage-list .post-actions { margin-left: 0; width: 100%; }
  .manage-list .post-comments { margin: 0 14px 14px; }

  /* 表单与面板在手机上更紧凑 */
  .admin-form { margin: 20px auto; }
  .admin-form textarea { height: 280px; }
  .edit-panel, #delete-panel { padding: 16px; }
  .edit-panel textarea { height: 240px; }
  .del-content { max-height: 240px; }

  /* 分页：缩小按钮并让页码信息单独成行，避免溢出 */
  .pager { gap: 6px; margin: 22px 0 6px; }
  .pager button { min-width: 34px; height: 34px; padding: 0 9px; font-size: 13px; }
  .pager-info { width: 100%; text-align: center; margin: 4px 0 0; }
}

/* 主页笔记卡片：分享按钮 */
.post-card-actions {
  display: flex;
  justify-content: flex-end;
  padding: 0 18px 14px;
}
.share-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  padding: 5px 14px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.share-btn:hover { border-color: var(--accent); color: var(--accent); }

/* 评论区（主页展开后） */
.comments {
  margin-top: 26px;
  border-top: 1px dashed var(--line);
  padding-top: 18px;
}
.comments-title { font-size: 16px; color: var(--accent); margin: 0 0 14px; }
.comment-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.comment-item {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
}
.comment-text { white-space: pre-wrap; word-break: break-word; font-size: 15px; line-height: 1.6; }
.comment-meta { margin-top: 6px; color: var(--muted); font-size: 12px; }
.comment-empty { color: var(--muted); padding: 4px 0 12px; }
.comment-form textarea {
  width: 100%;
  min-height: 64px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--fg);
  font: 15px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: vertical;
}
.comment-form-row { display: flex; gap: 12px; margin-top: 12px; }
.comment-form-row .comment-key {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--fg);
  font-size: 15px;
}
.comment-submit {
  background: var(--accent);
  color: #0f172a;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  padding: 10px 24px;
  font-size: 15px;
  cursor: pointer;
}
.comment-submit:hover { background: var(--accent-2); }
.comment-msg { min-height: 20px; margin: 10px 0 0; font-size: 14px; }

/* 评论管理列表中的操作按钮（操作锁禁用样式） */
.manage-list.locked .comment-actions button {
  opacity: 0.4;
  pointer-events: none;
  cursor: default;
}

@media (max-width: 600px) {
  .comment-form-row { flex-direction: column; }
  .comment-form-row .comment-submit { width: 100%; }
  .post-card-actions { padding: 0 14px 12px; }
}

/* 管理页：编辑/删除/评论面板内联插槽（点击时面板移入对应条目下方） */
.op-slot { margin: 0 18px; }
.op-slot:not(:empty) { margin-bottom: 14px; }
.comment-row { flex-wrap: wrap; }
.comment-row > .op-slot { flex-basis: 100%; margin: 0; }
.comment-row > .op-slot:not(:empty) { margin: 6px 0 2px; }
