:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1f2329;
  --muted: #8a9099;
  --border: #e8eaed;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --soft: #eff4ff;
  --danger: #dc2626;
  --shadow: 0 1px 3px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .04);
  --radius: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

body.modal-open { overflow: hidden; }

button, input, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  height: 64px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 19px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: .5px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  font-size: 17px;
}

.nav { display: flex; gap: 4px; }

.nav-item {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 8px;
  font-weight: 600;
}

.nav-item:hover { background: #f2f4f7; color: var(--text); }
.nav-item.active { color: var(--primary); background: var(--soft); }

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-area { display: flex; align-items: center; }
.user-menu { display: flex; align-items: center; gap: 10px; }
.user-name { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: 14px; }

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

/* ---------- 布局 ---------- */
.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 20px 60px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero { padding: 28px 30px; margin-bottom: 22px; background: linear-gradient(120deg, #ffffff 0%, #f4f8ff 100%); }
.hero h1 { margin: 0 0 6px; font-size: 25px; letter-spacing: -.5px; }
.hero p { margin: 0; color: var(--muted); }

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 2px 12px;
}
.list-header h2 { margin: 0; font-size: 17px; }

.text-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 6px;
}
.text-btn:hover { color: var(--primary); background: var(--soft); }

/* ---------- 帖子卡片 ---------- */
.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 12px;
  transition: box-shadow .18s ease, transform .18s ease;
  cursor: pointer;
}
.post-card:hover { box-shadow: 0 8px 24px rgba(16, 24, 40, .09); transform: translateY(-1px); }

.post-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.post-meta .author { color: var(--text); font-weight: 600; font-size: 14px; }
.sep { color: #c8ccd2; }

.post-title { margin: 12px 0 6px; font-size: 18px; line-height: 1.45; }
.post-excerpt {
  margin: 0;
  color: #4b5563;
  font-size: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-images { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.post-images.single { grid-template-columns: minmax(0, 300px); }
.post-images img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  background: #f0f1f3;
  cursor: zoom-in;
}
.more-images {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  background: #f0f1f3;
  color: var(--muted);
  font-weight: 700;
}

.post-actions { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.action {
  border: 1px solid transparent;
  background: #f6f7f9;
  color: var(--muted);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 13px;
}
.action:hover { background: var(--soft); color: var(--primary); }
.action.liked { background: var(--soft); color: var(--primary); font-weight: 600; }

.load-more-wrap { text-align: center; margin-top: 18px; }
.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty p { margin: 4px 0; }

/* ---------- 侧栏 ---------- */
.side-column { display: grid; gap: 14px; position: sticky; top: 88px; }
.side-card { padding: 20px; }
.side-card h3 { margin: 0 0 10px; font-size: 15px; }
.side-card p { margin: 0; color: #5b6472; font-size: 14px; }
.tips { margin: 0; padding-left: 18px; color: #5b6472; font-size: 14px; }
.tips li { margin: 6px 0; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.stats div { display: flex; flex-direction: column; align-items: center; }
.stats strong { font-size: 18px; color: var(--primary); }
.stats span { font-size: 12px; color: var(--muted); }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 18px;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.4;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-ghost { background: #fff; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- 表单 ---------- */
.form { display: flex; flex-direction: column; gap: 8px; }
.form label, .field-label { font-size: 13px; font-weight: 600; color: #4b5563; margin-top: 6px; }
.form input[type="text"], .form input[type="email"], .form input[type="password"], .form textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.form input:focus, .form textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.form textarea { resize: vertical; min-height: 160px; line-height: 1.7; }
.form-error { margin: 4px 0; color: var(--danger); font-size: 13px; min-height: 18px; }
.hint { color: var(--muted); font-size: 12px; }
.form-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.upload-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.upload-row .field-label { margin: 0; }

/* ---------- 弹窗 ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(17, 24, 39, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  position: relative;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(16, 24, 40, .25);
  width: 100%;
  max-height: min(88vh, 900px);
  overflow-y: auto;
  padding: 28px;
}
.modal-auth { max-width: 420px; }
.modal-compose { max-width: 720px; }
.modal-detail { max-width: 760px; }

.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.modal-head h2 { margin: 0; font-size: 20px; }

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
}
.modal-close:hover { background: #f2f4f7; color: var(--text); }
.modal-head .modal-close { position: static; flex: 0 0 auto; }

.auth-tabs { display: flex; gap: 6px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.auth-tab {
  border: 0;
  background: transparent;
  padding: 8px 14px 12px;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 2px solid transparent;
}
.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.image-previews { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 12px; }
.preview { position: relative; }
.preview img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.preview-status {
  position: absolute;
  left: 6px;
  bottom: 6px;
  background: rgba(17, 24, 39, .65);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 5px;
}
.preview-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: #1f2329;
  color: #fff;
  font-size: 15px;
  line-height: 1;
}

/* ---------- 帖子详情 ---------- */
.detail-body { padding-bottom: 8px; }
.detail-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.detail-meta .author { color: var(--text); font-weight: 600; font-size: 14px; }
.detail-content { font-size: 15.5px; line-height: 1.9; word-break: break-word; }
.detail-images { margin-top: 16px; }
.detail-images img { display: block; max-width: 100%; max-height: 460px; object-fit: contain; border-radius: 8px; margin-bottom: 10px; cursor: zoom-in; background: #f5f6f8; }
.detail-actions { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 14px 0; margin: 12px 0 20px; }

.comments h3 { margin: 0 0 14px; font-size: 16px; }
.comment-list { display: grid; gap: 16px; margin-bottom: 18px; }
.comment { display: flex; gap: 10px; align-items: flex-start; }
.comment-body { flex: 1; min-width: 0; }
.comment-meta { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.comment-meta strong { font-weight: 600; }
.comment-meta span { color: var(--muted); }
.comment-text { margin-top: 3px; color: #374151; word-break: break-word; }
.comment-form { display: flex; gap: 8px; }
.comment-form input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  outline: none;
}
.comment-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.muted { color: var(--muted); font-size: 14px; }

/* ---------- 大图 / 提示 ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(17, 24, 39, .88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%);
  z-index: 100;
  background: #1f2329;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
}
.toast.error { background: var(--danger); }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .container { grid-template-columns: 1fr; }
  .side-column { display: none; }
}

@media (max-width: 600px) {
  .topbar-inner { gap: 12px; padding: 0 14px; }
  .brand { font-size: 17px; }
  .brand-mark { width: 28px; height: 28px; font-size: 15px; }
  .nav-item { padding: 6px 9px; }
  .top-actions { gap: 6px; }
  .user-name { font-size: 0; gap: 0; }
  .container { padding: 18px 12px 40px; }
  .hero { padding: 20px; }
  .hero h1 { font-size: 21px; }
  .post-card { padding: 16px; }
  .modal { padding: 20px; }
  .image-previews { grid-template-columns: repeat(3, 1fr); }
  .form-footer { flex-direction: column; align-items: stretch; }
}
