:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-soft: #fbfcff;
  --text: #1b1f2e;
  --muted: #71788c;
  --line: #e6e9f2;
  --primary: #3b5bff;
  --primary-dark: #2a47d8;
  --primary-soft: #eef1ff;
  --accent: #ff7a45;
  --accent-soft: #fff1ea;
  --green: #17966b;
  --radius: 16px;
  --shadow-sm: 0 2px 8px rgba(24, 34, 72, .04);
  --shadow-md: 0 12px 32px rgba(24, 34, 72, .08);
  --shadow-lg: 0 24px 64px rgba(24, 34, 72, .16);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  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;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

.wrap { width: min(1180px, calc(100% - 48px)); margin: 0 auto; }
.muted { color: var(--muted); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  display: flex; align-items: center; gap: 28px;
  height: 72px;
}
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), #7b5bff);
  color: #fff; font-weight: 800; font-size: 19px;
  box-shadow: 0 6px 16px rgba(59, 91, 255, .28);
}
.brand-text { font-size: 19px; font-weight: 600; letter-spacing: -.3px; }
.brand-text b { color: var(--primary); }

.search {
  flex: 1; max-width: 460px;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 5px 5px 15px;
  transition: border-color .18s, box-shadow .18s;
}
.search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(59, 91, 255, .09);
}
.search svg {
  width: 17px; height: 17px; flex-shrink: 0;
  fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round;
}
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  font-size: 14px;
}
.search input::placeholder { color: #9aa1b3; }
.search button {
  border: 0; border-radius: 999px; padding: 7px 18px;
  background: var(--primary); color: #fff; font-size: 13px; font-weight: 600;
  transition: background .18s;
}
.search button:hover { background: var(--primary-dark); }

.account { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.user-pill {
  display: flex; align-items: center; gap: 9px;
  background: var(--primary-soft); color: var(--primary-dark);
  border-radius: 999px; padding: 6px 8px 6px 12px; font-size: 13px; font-weight: 600;
}
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: grid; place-items: center; font-size: 12px;
}

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid transparent; border-radius: 10px;
  padding: 9px 18px; font-size: 14px; font-weight: 600;
  transition: transform .15s, background .18s, border-color .18s, box-shadow .18s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(59, 91, 255, .2); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; border-color: var(--line); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 6px 13px; font-size: 13px; border-radius: 8px; }
.link-btn {
  border: 0; background: transparent; color: var(--primary);
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- 栏目栏 ---------- */
.catbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.catbar-inner { display: flex; align-items: center; gap: 16px; min-height: 58px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 0; }
.chip {
  border: 1px solid transparent; background: transparent;
  border-radius: 999px; padding: 6px 15px;
  font-size: 13.5px; color: var(--muted); font-weight: 500;
  transition: background .18s, color .18s;
}
.chip:hover { background: var(--bg); color: var(--text); }
.chip.active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 700; }
.catbar-inner .link-btn { margin-left: auto; }

/* ---------- Hero ---------- */
.hero {
  margin: 32px 0 30px;
  display: flex; align-items: center; justify-content: space-between; gap: 40px;
  background: linear-gradient(120deg, #eef1ff 0%, #f7f8ff 48%, #fff3ec 100%);
  border: 1px solid #e9ecff;
  border-radius: 22px;
  padding: 34px 38px;
  overflow: hidden;
  position: relative;
}
.hero::after {
  content: ""; position: absolute; right: -70px; top: -110px;
  width: 280px; height: 280px; border-radius: 50%;
  background: radial-gradient(circle, rgba(59, 91, 255, .10), transparent 70%);
}
.hero-copy { position: relative; z-index: 1; }
.badge {
  display: inline-block; background: #fff; color: var(--primary-dark);
  border: 1px solid #dfe4ff; border-radius: 999px;
  padding: 4px 12px; font-size: 12px; font-weight: 600; margin-bottom: 14px;
}
.hero h1 { margin: 0 0 8px; font-size: 30px; letter-spacing: -.8px; line-height: 1.35; }
.hero p { margin: 0; color: #5d6580; font-size: 14.5px; max-width: 560px; }
.hero-stats { display: flex; gap: 34px; position: relative; z-index: 1; flex-shrink: 0; }
.stat { text-align: center; }
.stat-num { display: block; font-size: 27px; font-weight: 800; letter-spacing: -1px; color: var(--primary-dark); }
.stat-label { font-size: 12px; color: #7a829a; }

/* ---------- 列表 ---------- */
.section-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 18px;
}
.section-head h2 { margin: 0; font-size: 21px; letter-spacing: -.4px; }
.section-head p { margin: 2px 0 0; font-size: 13px; }

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px;
  display: flex; flex-direction: column; min-height: 218px;
  box-shadow: var(--shadow-sm);
  transition: transform .18s, box-shadow .18s, border-color .18s;
  cursor: pointer;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: #d7ddff;
}
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 13px; }
.cat-tag {
  font-size: 11.5px; font-weight: 700; color: var(--primary-dark);
  background: var(--primary-soft); border-radius: 6px; padding: 3px 9px;
}
.card-date { font-size: 12px; color: #9aa1b3; white-space: nowrap; }
.card h3 { margin: 0 0 9px; font-size: 16.5px; line-height: 1.5; letter-spacing: -.2px; }
.card p { margin: 0 0 16px; color: var(--muted); font-size: 13.5px; line-height: 1.7; flex: 1; }
.card-foot {
  display: flex; align-items: center; gap: 14px;
  border-top: 1px solid var(--line); padding-top: 13px;
  font-size: 12.5px; color: var(--muted);
}
.card-foot .spacer { flex: 1; }
.icon-btn {
  border: 0; background: transparent; color: var(--muted);
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 4px;
  font-size: 12.5px; border-radius: 6px;
}
.icon-btn:hover { color: var(--accent); }
.icon-btn.on { color: var(--accent); font-weight: 700; }
.icon-btn svg, .fav-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.icon-btn.on svg, .fav-btn.on svg { fill: currentColor; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tag { font-size: 11.5px; color: #7c8398; background: var(--bg); border-radius: 5px; padding: 2px 8px; }

.empty {
  grid-column: 1 / -1; text-align: center; padding: 64px 20px;
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius);
}
.empty h3 { margin: 0 0 6px; font-size: 17px; }
.empty p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

.pager { display: flex; justify-content: center; gap: 8px; margin: 28px 0 8px; }
.page-btn {
  min-width: 36px; height: 36px; padding: 0 10px;
  border: 1px solid var(--line); background: #fff; border-radius: 9px;
  font-size: 13.5px; color: var(--muted);
}
.page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.page-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- 详情 ---------- */
.detail-back { margin: 4px 0 18px; }
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.article-panel { padding: 40px 48px; }
.article-panel h1 { margin: 14px 0 12px; font-size: 29px; line-height: 1.4; letter-spacing: -.7px; }
.article-meta {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  color: var(--muted); font-size: 13px; padding-bottom: 22px; border-bottom: 1px solid var(--line);
}
.article-summary {
  background: var(--primary-soft); border-left: 3px solid var(--primary);
  padding: 14px 18px; border-radius: 0 10px 10px 0;
  margin: 24px 0; color: #3a4470; font-size: 14.5px;
}
.article-body { font-size: 15.5px; line-height: 2.05; color: #30364a; }
.article-body p { margin: 0 0 18px; }
.article-actions { display: flex; gap: 10px; align-items: center; margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.fav-btn.on { background: var(--accent-soft); border-color: #ffd6c2; color: var(--accent); }

.comments { margin: 22px 0 40px; padding: 28px 32px; }
.comments h2 { margin: 0 0 18px; font-size: 18px; }
.comment-form { display: flex; gap: 10px; margin-bottom: 22px; }
.comment-form textarea {
  flex: 1; resize: vertical; min-height: 72px;
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px; outline: 0;
}
.comment-form textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,91,255,.08); }
.comment-item { display: flex; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.comment-item:first-of-type { border-top: 0; }
.comment-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: var(--bg); color: var(--primary-dark);
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
}
.comment-main { flex: 1; min-width: 0; }
.comment-head { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); }
.comment-head b { color: var(--text); font-size: 13.5px; }
.comment-body { margin: 4px 0 0; font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.login-hint {
  background: var(--bg); border-radius: 10px; padding: 14px 16px;
  font-size: 13.5px; color: var(--muted); margin-bottom: 20px;
}
.login-hint button { border: 0; background: transparent; color: var(--primary); font-weight: 700; padding: 0; }

/* ---------- 发布 ---------- */
.publish-panel { padding: 30px 34px; margin-bottom: 40px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.panel-head h2 { margin: 0; font-size: 20px; }
.form-stack { display: flex; flex-direction: column; gap: 17px; }
.form-stack label { display: flex; flex-direction: column; gap: 7px; font-size: 13.5px; font-weight: 600; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-stack input, .form-stack select, .form-stack textarea {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 13px;
  outline: 0; background: var(--surface-soft); font-size: 14px; font-weight: 400;
  transition: border-color .18s, box-shadow .18s;
}
.form-stack textarea { resize: vertical; line-height: 1.8; }
.form-stack input:focus, .form-stack select:focus, .form-stack textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59, 91, 255, .08);
}
.form-error { margin: 0; color: #d64545; font-size: 13px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- 模态 ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(20, 26, 48, .42); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 20px;
}
.modal-card {
  width: min(420px, 100%); background: #fff;
  border-radius: 18px; padding: 30px; box-shadow: var(--shadow-lg);
  animation: pop .18s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-card h2 { margin: 0 0 6px; font-size: 21px; }
.modal-sub { margin: 0 0 22px; color: var(--muted); font-size: 13.5px; }
.modal-tabs { display: flex; gap: 8px; margin-bottom: 20px; background: var(--bg); padding: 4px; border-radius: 10px; }
.modal-tabs button {
  flex: 1; border: 0; background: transparent; border-radius: 8px;
  padding: 8px; font-size: 14px; font-weight: 600; color: var(--muted);
}
.modal-tabs button.active { background: #fff; color: var(--primary); box-shadow: var(--shadow-sm); }
.modal-card .form-stack { gap: 14px; }
.modal-card .btn { width: 100%; }
.modal-switch { text-align: center; margin: 16px 0 0; font-size: 13px; color: var(--muted); }
.modal-switch button { border: 0; background: transparent; color: var(--primary); font-weight: 700; padding: 0; }
.modal-close { position: absolute; }
.sub-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px;
}
.sub-row:last-of-type { border-bottom: 0; }

/* ---------- Toast / Footer ---------- */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  z-index: 80; background: #20263a; color: #fff;
  padding: 11px 22px; border-radius: 10px; font-size: 14px;
  box-shadow: var(--shadow-lg); animation: pop .18s ease-out;
}
.toast.error { background: #c33b3b; }
.footer { margin-top: 56px; border-top: 1px solid var(--line); background: #fff; }
.footer-inner {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 22px 0; font-size: 13px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1000px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { padding: 28px; }
  .hero-stats { gap: 22px; }
  .article-panel { padding: 30px; }
}
@media (max-width: 720px) {
  .wrap { width: min(100% - 28px, 1180px); }
  .topbar-inner { height: auto; padding: 12px 0; flex-wrap: wrap; gap: 12px; }
  .search { order: 3; max-width: none; width: 100%; flex: auto; }
  .account { margin-left: auto; }
  .hero { flex-direction: column; align-items: flex-start; gap: 22px; padding: 26px 22px; }
  .hero h1 { font-size: 24px; }
  .grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .article-panel { padding: 24px 20px; }
  .article-panel h1 { font-size: 22px; }
  .comments { padding: 22px 20px; }
  .publish-panel { padding: 22px 18px; }
  .section-head { align-items: flex-start; }
}
