:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #171a1f;
  --muted: #667085;
  --border: #e4e7ec;
  --accent: #0f766e;
  --accent-hover: #115e59;
  --accent-soft: #d7f3ef;
  --danger: #d92d20;
  --danger-soft: #fee4e2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 6px 20px rgba(16, 24, 40, 0.05);
  --wrap: 920px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

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

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

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 62px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.2px;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(135deg, #14b8a6, #0f766e);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.28);
}
.brand-name { font-size: 16px; }

.nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.nav-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  padding: 4px 6px 4px 10px;
  border-radius: 999px;
  background: #f2f4f7;
}

/* ---------- 通用按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; background: #f2f4f7; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(15, 118, 110, 0.25);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-ghost { border-color: var(--border); }
.btn-danger { color: var(--danger); border-color: #fecdca; background: #fff; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ---------- 首页 ---------- */
.main { padding-top: 22px; padding-bottom: 64px; min-height: 60vh; }

.hero {
  padding: 6px 0 18px;
}
.hero h1 {
  margin: 0 0 6px;
  font-size: 24px;
  letter-spacing: -0.3px;
}
.hero p { margin: 0; color: var(--muted); font-size: 14px; }

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.search {
  position: relative;
  flex: 1 1 260px;
  min-width: 220px;
}
.search input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  color: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}
.search::before {
  content: "🔍";
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  opacity: 0.55;
  pointer-events: none;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 2px 1px 10px;
}
.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.chip:hover { border-color: #cfd4dc; color: var(--text); }
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.chip .count {
  font-size: 11.5px;
  font-weight: 600;
  opacity: 0.75;
}

.sortbar {
  display: flex;
  gap: 4px;
  margin: 4px 0 14px;
  border-bottom: 1px solid var(--border);
}
.tab {
  padding: 9px 12px;
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- 帖子卡片 ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }

.post {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.post:hover {
  border-color: #c9d2dc;
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.post-head { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  background: #f2f4f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.tag-pin { background: #fff4e5; color: #b54708; }
.tag-locked { background: #f2f4f7; color: #475467; }
.tag-accent { background: var(--accent-soft); color: var(--accent); }

.post-title {
  margin: 0 0 4px;
  font-size: 17px;
  line-height: 1.45;
  font-weight: 700;
  letter-spacing: -0.2px;
}
.post-excerpt {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13.5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.post-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12.5px;
  flex-wrap: wrap;
}
.post-meta .spacer { flex: 1; }
.post-meta .stat { display: inline-flex; align-items: center; gap: 4px; }
.post-meta .stat strong { color: var(--text); font-weight: 600; }

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

.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--muted);
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty .big { font-size: 30px; display: block; margin-bottom: 8px; }

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
  color: var(--muted);
  font-size: 13.5px;
}

/* ---------- 详情 ---------- */
.back { display: inline-block; margin-bottom: 14px; font-size: 14px; }

.detail {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 26px;
}
.detail-title {
  margin: 8px 0 10px;
  font-size: 23px;
  line-height: 1.4;
  letter-spacing: -0.4px;
}
.detail-body {
  margin: 18px 0 8px;
  font-size: 15.5px;
  line-height: 1.85;
  word-break: break-word;
}
.detail-body p { margin: 0 0 12px; }
.detail-body p:last-child { margin-bottom: 0; }
.detail-body code {
  background: #f2f4f7;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 0.9em;
  font-family: "Cascadia Code", Consolas, "Courier New", monospace;
}
.detail-body pre.code {
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px 16px;
  border-radius: 10px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.65;
  margin: 0 0 14px;
}
.detail-body pre.code code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}
.detail-body a { text-decoration: underline; text-underline-offset: 2px; }
.detail-body ul,
.reply-body ul { margin: 0 0 12px; padding-left: 22px; }
.detail-body li,
.reply-body li { margin: 4px 0; }

.detail-actions {
  display: flex;
  gap: 8px;
  padding-top: 16px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

/* ---------- 回复 ---------- */
.replies { margin-top: 18px; }
.replies h2 {
  font-size: 16px;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.reply {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.reply-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12.5px;
  margin-bottom: 8px;
}
.reply-meta .spacer { flex: 1; }
.reply-body {
  font-size: 14.5px;
  line-height: 1.75;
  word-break: break-word;
}
.reply-body p { margin: 0 0 8px; }
.reply-body p:last-child { margin-bottom: 0; }
.reply-body code {
  background: #f2f4f7;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 0.9em;
  font-family: "Cascadia Code", Consolas, "Courier New", monospace;
}
.reply-body pre.code {
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px 14px;
  border-radius: 9px;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.6;
  margin: 0 0 10px;
}
.reply-body pre.code code { background: none; border: none; padding: 0; color: inherit; }

.reply-form { margin-top: 14px; }

/* ---------- 表单 ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13.5px; font-weight: 600; color: #344054; }
.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field textarea { resize: vertical; min-height: 120px; line-height: 1.7; }
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}
.hint { color: var(--muted); font-size: 12.5px; }
.form-error { color: var(--danger); font-size: 13.5px; min-height: 0; }
.form-actions { display: flex; gap: 10px; align-items: center; }

.auth-card {
  max-width: 420px;
  margin: 40px auto 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 30px 30px 26px;
  box-shadow: var(--shadow);
}
.auth-card h1 { margin: 0 0 4px; font-size: 21px; }
.auth-card .sub { color: var(--muted); font-size: 13.5px; margin: 0 0 20px; }
.auth-alt { text-align: center; margin-top: 16px; color: var(--muted); font-size: 13.5px; }

.profile { display: flex; flex-direction: column; gap: 14px; }
.profile .card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
}
.profile h2 { margin: 0 0 12px; font-size: 16px; }
.kv { display: flex; gap: 10px; font-size: 14px; color: var(--muted); }
.kv strong { color: var(--text); }

/* ---------- 图片 ---------- */
.picker { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pick-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  background: var(--card);
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.pick-btn:hover { border-color: var(--accent); color: var(--accent); }
.pick-count { color: var(--muted); font-weight: 400; font-size: 12px; }

.previews { display: flex; flex-wrap: wrap; gap: 8px; }
.previews:not(:empty) { margin-top: 10px; }
.preview {
  position: relative;
  width: 92px;
  height: 92px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
}
.preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview-del,
.img-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.preview-del:hover,
.img-del:hover { background: var(--danger); }

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  margin-top: 14px;
}
.image-grid.compact { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); margin-top: 10px; }

.image-single { margin-top: 14px; }
.image-single .thumb {
  display: inline-block;
  max-width: 100%;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #0f172a;
  cursor: zoom-in;
  line-height: 0;
}
.image-single img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 420px;
}
.image-single.compact { margin-top: 10px; }
.image-single.compact img { max-height: 280px; }
.image-grid .thumb {
  position: relative;
  display: block;
  width: 100%;
  height: 130px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #000;
  cursor: zoom-in;
}
.image-grid.compact .thumb { height: 96px; }
.image-grid .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.15s;
}
.image-grid .thumb:hover img { transform: scale(1.03); }
.edit-grid .thumb { cursor: default; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  padding: 24px;
  cursor: zoom-out;
}
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* ---------- 其他 ---------- */
.loading { text-align: center; color: var(--muted); padding: 50px 0; font-size: 14px; }
.footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 22px;
  padding-bottom: 30px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12.5px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(8px);
  background: #101828;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 8px 30px rgba(16, 24, 40, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
  max-width: calc(100vw - 40px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #b42318; }

.muted { color: var(--muted); }
.center { text-align: center; }

@media (max-width: 640px) {
  .wrap { padding: 0 14px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .brand-name { display: none; }
  .hero h1 { font-size: 20px; }
  .detail { padding: 18px 16px; }
  .detail-title { font-size: 19px; }
  .post { padding: 14px 14px; }
  .auth-card { padding: 24px 20px; margin-top: 20px; }
  .nav-user span.name { max-width: 84px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --card: #171b21;
    --text: #e8eaed;
    --muted: #98a2b3;
    --border: #262c35;
    --accent: #2dd4bf;
    --accent-hover: #14b8a6;
    --accent-soft: #123c37;
    --danger: #f97066;
    --danger-soft: #3b1219;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
  }
  .topbar { background: rgba(15, 18, 22, 0.86); }
  .nav-user { background: #1d232b; }
  .btn { background: var(--card); }
  .btn:hover { background: #1d232b; }
  .btn-primary { background: var(--accent); color: #06201d; }
  .search input, .field input, .field textarea, .field select { background: #10141a; }
  .chip { background: var(--card); }
  .chip.active { background: var(--accent); color: #06201d; }
  .tag { background: #1d232b; }
  .tag-pin { background: #3a2a12; color: #fdb022; }
  .field > label { color: #cfd4dc; }
}
