* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #2563EB; --primary-dark: #1D4ED8;
  --bg: #F8FAFC; --surface: #FFFFFF;
  --text: #1E293B; --text-secondary: #64748B; --text-light: #94A3B8;
  --border: #E2E8F0; --tag-bg: #EFF6FF; --tag-text: #2563EB;
  --danger: #EF4444; --radius: 12px;
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; }


.header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.header-content { max-width: 1400px; margin: 0 auto; padding: 12px 24px; display: flex; justify-content: space-between; align-items: center; }
.logo { font-size: 24px; font-weight: 800; color: var(--primary); cursor: pointer; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.user-info { font-size: 13px; color: var(--text-secondary); }
.btn-primary { background: var(--primary); color: white; border: none; padding: 10px 20px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--text-secondary); border: 1px solid var(--border); padding: 10px 20px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-danger { background: var(--danger); color: white; border: none; padding: 10px 20px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-sm { padding: 6px 14px; font-size: 13px; }


/* Login */
.login-container { display: flex; justify-content: center; align-items: center; min-height: 70vh; }
.login-box { background: var(--surface); padding: 40px; border-radius: 16px; width: 100%; max-width: 380px; box-shadow: 0 4px 24px rgba(0,0,0,0.08); }
.login-title { text-align: center; margin-bottom: 24px; font-size: 22px; }
.login-hint { text-align: center; margin-top: 16px; font-size: 12px; color: var(--text-light); }

/* Search */
.search-bar { max-width: 1400px; margin: 24px auto 0; padding: 0 24px; display: flex; gap: 8px; align-items: center; }
.search-input { flex: 1; padding: 10px 16px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; max-width: 400px; }
.search-input:focus { outline: none; border-color: var(--primary); }

/* Home Layout with Tag Sidebar */
.home-layout { max-width: 1400px; margin: 0 auto; padding: 24px; display: flex; gap: 24px; }
.tag-sidebar { width: 200px; flex-shrink: 0; background: var(--surface); border-radius: 12px; padding: 16px; height: fit-content; position: sticky; top: 80px; box-shadow: 0 1px 4px rgba(0,0,0,0.04); }
.tag-sidebar-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; color: var(--text); }
.tag-sidebar-item { display: flex; justify-content: space-between; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text-secondary); }
.tag-sidebar-item:hover { background: var(--tag-bg); color: var(--primary); }
.tag-sidebar-item.active { background: var(--primary); color: white; }
.tag-count { font-size: 12px; background: var(--bg); padding: 1px 6px; border-radius: 10px; }
.tag-sidebar-item.active .tag-count { background: rgba(255,255,255,0.2); color: white; }


/* Post List */
.post-list { flex: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; align-content: start; }
.post-card { background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.06); transition: transform 0.2s, box-shadow 0.2s; cursor: pointer; }
.post-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,0.1); }
.post-card-body { padding: 18px; }
.post-card-title { font-size: 16px; font-weight: 700; margin-bottom: 6px; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.draft-badge { display: inline-block; background: #FEF3C7; color: #D97706; padding: 1px 6px; border-radius: 4px; font-size: 11px; font-weight: 600; margin-right: 4px; }
.post-card-summary { font-size: 13px; color: var(--text-secondary); margin-bottom: 10px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-card-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-light); margin-bottom: 6px; }
.post-card-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tag { background: var(--tag-bg); color: var(--tag-text); padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 500; }

/* Detail */
.post-detail { max-width: 800px; margin: 0 auto; padding: 24px; }
.detail-top-actions, .detail-bottom-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.detail-bottom-actions { margin-top: 32px; margin-bottom: 0; padding-top: 12px; border-top: 1px solid var(--border); border-bottom: none; }
.detail-top-right { display: flex; gap: 8px; }
.post-detail-header { margin-bottom: 24px; }
.post-detail-title { font-size: 28px; font-weight: 800; line-height: 1.3; margin-bottom: 10px; }
.post-detail-meta { color: var(--text-secondary); font-size: 13px; }
.toc { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-bottom: 24px; }
.toc-title { font-weight: 700; margin-bottom: 8px; font-size: 14px; }
.toc-item { color: var(--primary); font-size: 13px; padding: 3px 0; cursor: pointer; }


/* Markdown Content */
.markdown-content h1 { font-size: 26px; font-weight: 800; margin: 28px 0 14px; }
.markdown-content h2 { font-size: 21px; font-weight: 700; margin: 24px 0 10px; }
.markdown-content h3 { font-size: 17px; font-weight: 600; margin: 20px 0 8px; }
.markdown-content h4 { font-size: 15px; font-weight: 600; margin: 16px 0 6px; color: var(--text-secondary); }
.markdown-content p { margin-bottom: 12px; line-height: 1.8; }
.markdown-content ul, .markdown-content ol { padding-left: 24px; margin-bottom: 12px; }
.markdown-content li { margin-bottom: 4px; line-height: 1.6; }
.markdown-content img { max-width: 100%; border-radius: 8px; margin: 12px 0; }
.markdown-content table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 14px; }
.markdown-content th { background: var(--bg); font-weight: 600; text-align: left; padding: 10px 12px; border: 1px solid var(--border); }
.markdown-content td { padding: 10px 12px; border: 1px solid var(--border); }
.markdown-content code { background: #F1F5F9; padding: 2px 6px; border-radius: 4px; font-size: 13px; font-family: 'SFMono-Regular','Consolas',monospace; color: #E11D48; }
.markdown-content pre { background: #1E293B; color: #E2E8F0; padding: 20px; border-radius: 8px; overflow-x: auto; margin: 16px 0; position: relative; line-height: 1.5; }
.markdown-content pre .code-lang { position: absolute; top: 8px; right: 12px; font-size: 11px; color: #64748B; text-transform: uppercase; }
.markdown-content pre code { background: none; padding: 0; color: inherit; font-size: 13px; line-height: 1.6; white-space: pre; display: block; }
.markdown-content blockquote { border-left: 4px solid var(--primary); padding: 12px 16px; margin: 16px 0; background: var(--tag-bg); border-radius: 0 4px 4px 0; color: var(--text-secondary); font-style: italic; }
.markdown-content hr { border: none; height: 1px; background: var(--border); margin: 24px 0; }

/* Editor */
.editor-container { max-width: 100%; padding: 20px; }
.editor-input { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 15px; margin-bottom: 10px; font-family: inherit; }
.editor-input:focus { outline: none; border-color: var(--primary); }
.editor-title { font-size: 22px; font-weight: 700; }
.editor-summary { resize: vertical; min-height: 56px; line-height: 1.5; }
.editor-area { display: flex; gap: 0; min-height: 500px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.editor-textarea { flex: 1; width: 50%; padding: 20px; border: none; border-right: 1px solid var(--border); font-family: 'SFMono-Regular','Consolas',monospace; font-size: 14px; line-height: 1.6; resize: none; min-height: 500px; outline: none; background: var(--surface); }
.editor-preview { flex: 1; width: 50%; padding: 20px; overflow-y: auto; max-height: 600px; background: var(--surface); }
.editor-actions { display: flex; gap: 12px; margin-top: 14px; justify-content: flex-end; }


/* Misc */
.empty-state { text-align: center; padding: 80px 24px; color: var(--text-light); }
.empty-state-icon { font-size: 64px; margin-bottom: 16px; }
.empty-state-title { font-size: 18px; font-weight: 600; color: var(--text-secondary); }
.loading { text-align: center; padding: 40px; color: var(--text-light); }

/* Responsive */
@media (max-width: 768px) {
  .home-layout { flex-direction: column; padding: 16px; }
  .tag-sidebar { width: 100%; position: static; display: flex; flex-wrap: wrap; gap: 6px; padding: 12px; }
  .tag-sidebar-title { width: 100%; }
  .tag-sidebar-item { flex: none; }
  .post-list { grid-template-columns: 1fr; }
  .editor-area { flex-direction: column; }
  .editor-textarea { width: 100%; min-height: 300px; border-right: none; border-bottom: 1px solid var(--border); }
  .editor-preview { width: 100%; max-height: 400px; }
  .post-detail-title { font-size: 22px; }
  .search-bar { flex-wrap: wrap; }
  .search-input { max-width: 100%; }
  .detail-top-actions, .detail-bottom-actions { flex-wrap: wrap; gap: 8px; }
}
