/* ── Knowledge Platform ─────────────────────────────────────────── */
/* Design: clean, content-first, moderate whitespace               */
/* Font: Noto Sans SC (Chinese) + Inter (numbers/Latin)             */
/* ──────────────────────────────────────────────────────────────── */

:root {
  --bg: #f8f9fa;
  --bg-card: #ffffff;
  --bg-header: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --accent: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --max-width: 1100px;
  --header-h: 56px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }
body {
  font-family: 'Noto Sans SC', 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ──────────────────────────────────────────────────── */

.header {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
}
.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}
.logo:hover { text-decoration: none; opacity: 0.85; }

.nav { display: flex; align-items: center; gap: 4px; }
.nav-link {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius);
  transition: all 0.15s;
}
.nav-link:hover { color: var(--text); background: var(--bg); text-decoration: none; }
.nav-register {
  background: var(--primary);
  color: #fff;
}
.nav-register:hover { background: var(--primary-hover); color: #fff; }

.nav-dropdown { position: relative; }
.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 160px;
  z-index: 200;
  padding: 4px;
}
.nav-dropdown:hover .dropdown-menu { display: block; }
.dropdown-item {
  display: block;
  padding: 8px 14px;
  font-size: 0.88rem;
  color: var(--text);
  border-radius: 6px;
  transition: background 0.15s;
}
.dropdown-item:hover { background: var(--primary-light); text-decoration: none; }

.menu-toggle { display: none; background: none; border: none; font-size: 1.5rem; cursor: pointer; padding: 4px 8px; }

/* ── Main ─────────────────────────────────────────────────────── */

.main {
  flex: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px 20px;
  width: 100%;
}

/* ── Flash messages ──────────────────────────────────────────── */

.flash-container { margin-bottom: 20px; }
.flash {
  padding: 10px 16px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 0.9rem;
  animation: flashIn 0.3s ease;
  transition: opacity 0.3s ease;
}
.flash-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.flash-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.flash-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
@keyframes flashIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Hero ─────────────────────────────────────────────────────── */

.hero {
  text-align: center;
  padding: 48px 20px 32px;
}
.hero h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.hero-desc {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 24px;
}
.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── Buttons ──────────────────────────────────────────────────── */

.btn-primary, .btn-outline {
  display: inline-block;
  padding: 10px 24px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
}
.btn-primary:hover { background: var(--primary-hover); text-decoration: none; }
.btn-outline {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.btn-block { width: 100%; }
.btn-like {
  background: none;
  border: 1px solid var(--border);
  padding: 6px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.15s;
}
.btn-like:hover { border-color: var(--primary); }
.btn-like.liked { border-color: var(--danger); color: var(--danger); }
.btn-danger-sm {
  background: none;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
}
.btn-danger-sm:hover { background: var(--danger); color: #fff; }

/* ── Sections ─────────────────────────────────────────────────── */

.section { margin-bottom: 36px; }
.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}
.section-actions { margin-top: 16px; }
.text-muted { color: var(--text-muted); font-size: 0.9rem; }

/* ── Categories grid ──────────────────────────────────────────── */

.categories { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.category-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  transition: all 0.2s;
}
.category-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}
.category-info h3 { font-size: 1rem; font-weight: 600; margin-bottom: 4px; color: var(--text); }
.category-desc { font-size: 0.85rem; color: var(--text-muted); }
.category-count { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; padding-top: 4px; }

/* ── Post list ────────────────────────────────────────────────── */

.post-list { display: flex; flex-direction: column; gap: 1px; }
.post-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  transition: border-color 0.15s;
}
.post-row:hover { border-color: var(--primary); }
.post-row-main h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 4px; }
.post-row-main h3 a { color: var(--text); }
.post-row-main h3 a:hover { color: var(--primary); }
.post-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.meta-category {
  background: var(--primary-light);
  color: var(--primary);
  padding: 1px 8px;
  border-radius: 4px;
  font-weight: 500;
}

/* ── Full post ────────────────────────────────────────────────── */

.post-full {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 24px;
}
.post-header { margin-bottom: 20px; }
.post-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 8px; line-height: 1.4; }
.post-content {
  font-size: 0.95rem;
  line-height: 1.8;
}
.post-content p { margin-bottom: 12px; }
.post-content h1, .post-content h2, .post-content h3 { margin: 24px 0 12px; font-weight: 600; }
.post-content h1 { font-size: 1.3rem; }
.post-content h2 { font-size: 1.15rem; }
.post-content h3 { font-size: 1.05rem; }
.post-content ul, .post-content ol { margin: 8px 0 12px 20px; }
.post-content li { margin-bottom: 4px; }
.post-content blockquote {
  border-left: 3px solid var(--primary);
  padding: 8px 16px;
  margin: 12px 0;
  background: var(--primary-light);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.post-content code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
}
.post-content pre {
  background: #1f2937;
  color: #e5e7eb;
  padding: 16px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 12px 0;
}
.post-content pre code { background: none; padding: 0; color: inherit; }
.post-content img { max-width: 100%; border-radius: var(--radius); margin: 12px 0; }
.post-actions {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
}
.inline-form { display: inline; }

/* ── Comments ─────────────────────────────────────────────────── */

.comments-section { margin-top: 24px; }
.reply-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
}
.reply-form textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  margin-bottom: 12px;
}
.reply-form textarea:focus { outline: none; border-color: var(--primary); }
.comment {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 8px;
}
.comment-header { margin-bottom: 8px; display: flex; gap: 8px; align-items: center; }
.comment-author { font-weight: 600; font-size: 0.9rem; }
.comment-date { color: var(--text-muted); font-size: 0.8rem; }
.comment-body { font-size: 0.9rem; line-height: 1.7; }
.comment-body p { margin-bottom: 6px; }

/* ── Badges ─────────────────────────────────────────────────── */

.badge-admin-sm {
  background: #f59e0b;
  color: #fff;
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.badge-pinned {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  padding: 1px 8px;
  border-radius: 4px;
  font-weight: 600;
}

/* ── Auth ─────────────────────────────────────────────────────── */

.auth-page { display: flex; justify-content: center; padding: 40px 0; }
.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}
.auth-card h1 { text-align: center; margin-bottom: 24px; font-size: 1.3rem; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.88rem; font-weight: 500; color: var(--text); }
.form-group input, .form-group select, .form-group textarea {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-group textarea { resize: vertical; min-height: 120px; }
.auth-link { text-align: center; margin-top: 16px; font-size: 0.88rem; color: var(--text-muted); }

/* ── Profile ──────────────────────────────────────────────────── */

.profile-header {
  display: flex;
  gap: 20px;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 28px;
}
.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  flex-shrink: 0;
}
.profile-info h1 { font-size: 1.3rem; font-weight: 700; }
.profile-meta { font-size: 0.85rem; color: var(--text-muted); }
.profile-bio { margin-top: 8px; font-size: 0.9rem; }

/* ── Breadcrumb ───────────────────────────────────────────────── */

.breadcrumb {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding: 8px 0;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }

/* ── Page header ──────────────────────────────────────────────── */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h1 { font-size: 1.3rem; font-weight: 700; }
.header-actions { display: flex; gap: 8px; }

/* ── Pagination ───────────────────────────────────────────────── */

.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }
.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text);
  transition: all 0.15s;
}
.page-link:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Wiki ─────────────────────────────────────────────────────── */

.wiki-stats { display: flex; gap: 12px; margin-bottom: 24px; }
.stat-badge {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.wiki-layout { display: flex; gap: 24px; }
.wiki-sidebar {
  flex: 0 0 220px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: sticky;
  top: calc(var(--header-h) + 20px);
  max-height: calc(100vh - var(--header-h) - 40px);
  overflow-y: auto;
}
.wiki-sidebar h3 { font-size: 0.9rem; font-weight: 600; margin-bottom: 12px; }
.category-tree { list-style: none; }
.category-tree li { margin-bottom: 2px; }
.category-tree a {
  display: block;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text);
  transition: background 0.1s;
}
.category-tree a:hover { background: var(--primary-light); text-decoration: none; }
.category-tree a.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.count { color: var(--text-muted); font-size: 0.8rem; }

.wiki-content { flex: 1; min-width: 0; }
.wiki-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.wiki-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.wiki-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); text-decoration: none; }
.wiki-card h4 { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.wiki-card:hover h4 { color: var(--primary); }
.wiki-preview { font-size: 0.82rem; color: var(--text-muted); line-height: 1.5; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }

.tag {
  display: inline-block;
  background: #f3f4f6;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 4px;
  align-self: flex-start;
}

/* Wiki page */
.wiki-page-layout { display: flex; gap: 24px; }
.wiki-page-content { flex: 1; min-width: 0; }
.wiki-page-header { margin-bottom: 24px; }
.wiki-page-header h1 { font-size: 1.6rem; font-weight: 700; line-height: 1.3; }
.wiki-meta { margin-top: 8px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.wiki-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.wiki-body {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  font-size: 0.95rem;
  line-height: 1.8;
}
.wiki-body p { margin-bottom: 12px; }
.wiki-body h1, .wiki-body h2, .wiki-body h3 { margin: 28px 0 12px; font-weight: 600; }
.wiki-body h1 { font-size: 1.4rem; }
.wiki-body h2 { font-size: 1.2rem; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.wiki-body h3 { font-size: 1.05rem; }
.wiki-body ul, .wiki-body ol { margin: 8px 0 12px 20px; }
.wiki-body li { margin-bottom: 4px; }
.wiki-body blockquote {
  border-left: 3px solid var(--primary);
  padding: 8px 16px;
  margin: 12px 0;
  background: var(--primary-light);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.wiki-body code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
}
.wiki-body pre {
  background: #1f2937;
  color: #e5e7eb;
  padding: 16px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 12px 0;
}
.wiki-body pre code { background: none; padding: 0; color: inherit; }
.wiki-body img { max-width: 100%; border-radius: var(--radius); margin: 16px 0; }
.wiki-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
}
.wiki-body th, .wiki-body td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.wiki-body th { background: #f9fafb; font-weight: 600; }
.wiki-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.wiki-sidebar-page {
  flex: 0 0 240px;
}
.sidebar-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: sticky;
  top: calc(var(--header-h) + 20px);
}
.sidebar-card h4 { font-size: 0.9rem; font-weight: 600; margin-bottom: 10px; }
.sidebar-list { list-style: none; }
.sidebar-list li { margin-bottom: 2px; }
.sidebar-list a {
  display: block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.83rem;
  color: var(--text);
  transition: background 0.1s;
}
.sidebar-list a:hover { background: var(--primary-light); text-decoration: none; }
.sidebar-list a.active { color: var(--primary); font-weight: 500; }

.empty-state { text-align: center; padding: 60px 20px; }
.empty-state h1 { font-size: 2rem; margin-bottom: 12px; }
.empty-state p { color: var(--text-muted); margin-bottom: 8px; }
.empty-state code { background: #f3f4f6; padding: 2px 8px; border-radius: 4px; }
.empty { color: var(--text-muted); padding: 20px; text-align: center; font-size: 0.9rem; }

/* ── Search ──────────────────────────────────────────────────── */

.search-page { max-width: 700px; margin: 0 auto; }
.search-page h1 { text-align: center; margin-bottom: 24px; }
.search-form-big {
  display: flex;
  gap: 8px;
  margin-bottom: 32px;
}
.search-form-big input {
  flex: 1;
  padding: 12px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.15s;
}
.search-form-big input:focus { outline: none; border-color: var(--primary); }

/* ── Form page ────────────────────────────────────────────────── */

.form-page { max-width: 700px; margin: 0 auto; }
.form-page h1 { margin-bottom: 20px; }

/* ── Footer ───────────────────────────────────────────────────── */

.footer {
  background: var(--bg-header);
  border-top: 1px solid var(--border);
  margin-top: 40px;
  padding: 32px 0 0;
}
.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  gap: 48px;
  flex-wrap: wrap;
}
.footer-col h4 { font-size: 0.9rem; font-weight: 600; margin-bottom: 8px; }
.footer-col p { font-size: 0.85rem; color: var(--text-muted); }
.footer-link { display: block; font-size: 0.85rem; color: var(--text-muted); padding: 3px 0; }
.footer-link:hover { color: var(--primary); }
.footer-bottom {
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding: 16px 20px;
  text-align: center;
}
.footer-bottom p { font-size: 0.82rem; color: var(--text-muted); }

/* ── Responsive ───────────────────────────────────────────────── */

@media (max-width: 768px) {
  .header-inner { padding: 0 12px; }
  .nav { display: none; gap: 2px; }
  .nav.open { display: flex; flex-direction: column; position: absolute; top: var(--header-h); left: 0; right: 0; background: var(--bg-header); border-bottom: 1px solid var(--border); padding: 8px 12px; }
  .menu-toggle { display: block; }
  .wiki-layout { flex-direction: column; }
  .wiki-sidebar { flex: none; width: 100%; position: static; max-height: none; }
  .wiki-page-layout { flex-direction: column; }
  .wiki-sidebar-page { flex: none; width: 100%; }
  .sidebar-card { position: static; }
  .categories { grid-template-columns: 1fr; }
  .wiki-grid { grid-template-columns: 1fr; }
  .hero { padding: 32px 12px 24px; }
  .hero h1 { font-size: 1.5rem; }
  .post-full { padding: 20px; }
  .wiki-body { padding: 20px; }
  .auth-card { padding: 24px; }
}
