/* ========== 全局基础 ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 8px 24px rgba(37, 99, 235, 0.12);
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  min-height: 100vh;
}

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--primary-hover);
}

/* ========== 顶部导航 ========== */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 22px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.site-header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.site-header h1 {
  font-size: 22px;
  font-weight: 700;
}

.site-header h1 a {
  color: var(--text);
}

.site-header nav {
  display: flex;
  gap: 20px;
}

.site-header nav a {
  color: var(--text-secondary);
  font-size: 15px;
}

.site-header nav a:hover {
  color: var(--primary);
}

/* ========== 主体区域 ========== */
main {
  padding: 40px 0;
  min-height: calc(100vh - 180px);
}

/* ========== 首页文章卡片 ========== */
.post-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.post-item {
  background: var(--card);
  padding: 28px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: all 0.25s ease;
  cursor: pointer;
}

.post-item:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.post-item h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

.post-item h2 a {
  color: var(--text);
}

.post-item h2 a:hover {
  color: var(--primary);
}

.post-meta {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 12px;
  display: flex;
  gap: 16px;
}

.post-summary {
  color: var(--text-secondary);
  font-size: 15px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.readmore {
  display: inline-block;
  margin-top: 16px;
  font-size: 14px;
  font-weight: 500;
}

.empty-tip, .loading-tip {
  text-align: center;
  color: var(--text-secondary);
  padding: 60px 0;
  font-size: 15px;
}

/* ========== 文章详情页 ========== */
.post-detail {
  background: var(--card);
  padding: 36px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.post-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 12px;
  line-height: 1.4;
}

.post-meta-detail {
  color: var(--text-secondary);
  font-size: 14px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.post-content {
  font-size: 16px;
  color: var(--text);
}

.post-content h1, .post-content h2, .post-content h3, .post-content h4 {
  margin: 24px 0 12px;
  line-height: 1.4;
}

.post-content p {
  margin-bottom: 16px;
}

.post-content img {
  max-width: 100%;
  border-radius: 8px;
  margin: 16px 0;
}

.post-content code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 14px;
  font-family: "JetBrains Mono", Consolas, monospace;
}

.post-content pre {
  background: #1f2937;
  color: #f9fafb;
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 16px 0;
}

.post-content pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.post-content blockquote {
  border-left: 4px solid var(--primary);
  padding-left: 16px;
  color: var(--text-secondary);
  margin: 16px 0;
}

.post-content ul, .post-content ol {
  padding-left: 24px;
  margin-bottom: 16px;
}

/* ========== 评论区 ========== */
.comment-section {
  margin-top: 32px;
  background: var(--card);
  padding: 28px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.comment-section h3 {
  font-size: 18px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.comment-form {
  margin-bottom: 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.comment-form input, .comment-form textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  transition: border-color 0.2s;
}

.comment-form input:focus, .comment-form textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.comment-form textarea {
  resize: vertical;
  min-height: 90px;
}

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.comment-item {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.comment-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.comment-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.comment-nick {
  font-weight: 600;
  font-size: 15px;
  color: var(--primary);
}

.comment-time {
  color: var(--text-secondary);
  font-size: 13px;
}

.comment-content {
  color: var(--text);
  font-size: 15px;
  word-break: break-word;
}

/* ========== 后台页面 ========== */
.card {
  background: var(--card);
  padding: 28px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.card h3 {
  font-size: 18px;
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

input, textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  transition: border-color 0.2s;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}

textarea {
  resize: vertical;
}

/* 按钮样式 */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #f3f4f6;
  color: var(--text);
}

.btn-secondary:hover {
  background: #e5e7eb;
}

.btn-danger {
  background: #ef4444;
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-group {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

/* 文章管理列表 */
.manage-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.manage-item:last-child {
  border-bottom: none;
}

.manage-item-title {
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.manage-item-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* 富文本编辑器容器 */
#editor-toolbar {
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  padding: 8px;
  background: #f9fafb;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#editor-toolbar button {
  padding: 6px 10px;
  border: none;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  min-width: 32px;
  transition: all 0.15s;
}

#editor-toolbar button:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

#editor-content {
  min-height: 320px;
  border: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  padding: 16px;
  font-size: 15px;
  outline: none;
}

#editor-content:focus {
  border-color: var(--primary);
}

#editor-content img {
  max-width: 100%;
  border-radius: 8px;
}

/* ========== 页脚 ========== */
.site-footer {
  text-align: center;
  padding: 28px 0;
  color: var(--text-secondary);
  font-size: 14px;
  background: var(--card);
  border-top: 1px solid var(--border);
}

/* ========== 响应式适配 ========== */
@media (max-width: 640px) {
  .site-header .container {
    flex-direction: column;
    align-items: flex-start;
  }

  main {
    padding: 24px 0;
  }

  .post-item, .post-detail, .card, .comment-section {
    padding: 20px;
  }

  .post-title {
    font-size: 22px;
  }

  .manage-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .manage-item-actions {
    width: 100%;
    justify-content: flex-end;
  }
}
