:root {
  --primary: #ff6b35;
  --primary-dark: #e2571c;
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #2d3436;
  --muted: #8a94a6;
  --border: #e8ebf0;
  --radius: 14px;
  --shadow: 0 4px 18px rgba(0,0,0,.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ===== 顶部栏 ===== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: #fff; box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 1100px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.logo { font-size: 20px; font-weight: 800; color: var(--primary); white-space: nowrap; }
.logo a { color: inherit; text-decoration: none; }
.search {
  flex: 1; min-width: 200px; display: flex; gap: 8px;
}
.search input {
  flex: 1; padding: 10px 14px; border: 1px solid var(--border);
  border-radius: 999px; font-size: 14px; outline: none;
}
.search input:focus { border-color: var(--primary); }
.btn {
  background: var(--primary); color: #fff; border: none;
  padding: 10px 18px; border-radius: 999px; cursor: pointer;
  font-size: 14px; font-weight: 600; transition: .2s;
}
.btn:hover { background: var(--primary-dark); }
.btn.ghost { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.link-admin { color: var(--muted); font-size: 13px; text-decoration: none; }

/* AI 规划入口：默认隐藏，由 assets/js/api.js 探测 GET ai/status 后加 .ai-on 放行。
   默认隐藏而不是默认显示 —— 既避免「先闪一下再消失」，也保证站点没配大模型时
   不会露出一个点了才被告知「未开启」的无效入口。 */
[data-ai-entry] { display: none; }
[data-ai-entry].ai-on { display: inline-block; }

/* ===== 筛选区 ===== */
.filters { max-width: 1100px; margin: 16px auto 0; padding: 0 16px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 6px 14px; border-radius: 999px; background: #fff;
  border: 1px solid var(--border); cursor: pointer; font-size: 13px; color: var(--muted);
  text-decoration: none;   /* SSR 首页的 chip 是 <a>，去掉下划线 */
}
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
select.filter-sel {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 13px; background: #fff;
}

/* ===== 攻略列表 ===== */
.container { max-width: 1100px; margin: 16px auto 40px; padding: 0 16px; }
.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.card {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); cursor: pointer; transition: transform .2s, box-shadow .2s;
  display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-4px); box-shadow: 0 10px 28px rgba(0,0,0,.1); }
/* 服务端渲染页把卡片写成 <a>，便于爬虫抓取内链 */
a.card { text-decoration: none; color: inherit; }
.card-cover {
  height: 160px; background: linear-gradient(135deg, #ffd194, #ff6b35);
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 15px; padding: 12px; text-align: center;
}
.card-cover img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 14px 16px; flex: 1; display: flex; flex-direction: column; }
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.card-summary { font-size: 13px; color: var(--muted); flex: 1;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { margin-top: 10px; font-size: 12px; color: var(--muted); display: flex; gap: 12px; }

/* ===== 分页 ===== */
.pager { display: flex; gap: 8px; justify-content: center; margin-top: 28px; }
.pager button { padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: #fff; cursor: pointer; }
.pager button:disabled { opacity: .5; cursor: not-allowed; }

/* ===== 详情页 ===== */
.detail-wrap { max-width: 760px; margin: 20px auto 60px; padding: 0 16px; }
.detail-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.detail-title { font-size: 24px; font-weight: 800; margin-bottom: 10px; }
.detail-meta { color: var(--muted); font-size: 13px; margin-bottom: 16px; display: flex; gap: 14px; flex-wrap: wrap; }
.tag { display: inline-block; background: #fff2ea; color: var(--primary); padding: 3px 10px; border-radius: 999px; font-size: 12px; margin: 0 6px 6px 0; }
.detail-content { white-space: pre-wrap; font-size: 15px; line-height: 1.9; margin: 18px 0; }
.detail-actions { display: flex; gap: 12px; margin: 20px 0; }
.detail-actions .btn { flex: 1; }
.back { display: inline-block; margin: 14px 0; color: var(--primary); text-decoration: none; font-size: 14px; }
.related { margin-top: 30px; }
.related h3 { margin-bottom: 14px; }

/* ===== 后台 ===== */
.admin-wrap { max-width: 860px; margin: 20px auto 60px; padding: 0 16px; }
.form-card, .list-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px; }
.form-card h2, .list-card h2 { margin-bottom: 16px; font-size: 18px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 14px; font-family: inherit; outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--primary); }
.field textarea { min-height: 140px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.admin-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.admin-item:last-child { border-bottom: none; }
.admin-item .t { flex: 1; font-weight: 600; }
.admin-item .m { font-size: 12px; color: var(--muted); }
.admin-item[draggable="true"] { cursor: grab; user-select: none; }
.admin-item[draggable="true"]:active { cursor: grabbing; }
.admin-item.dragging { opacity: .4; }
.admin-item.drag-over { border: 2px dashed var(--primary); border-radius: 8px; background: rgba(255,107,53,.06); }
.admin-item.ro { cursor: default; user-select: auto; opacity: .92; }

/* ===== 只读态（协作者 viewer / 访客）===== */
.perm-bar {
  max-width: 760px; margin: 0 auto 14px; padding: 12px 16px;
  background: #fff8e6; border: 1px solid #ffe0a3; border-radius: 10px;
  color: #8a6414; font-size: 13px; line-height: 1.6;
}
.ro-tag {
  display: inline-block; background: #f0ad4e; color: #fff;
  padding: 1px 8px; border-radius: 999px; font-size: 12px;
  font-weight: 700; margin-right: 6px; vertical-align: middle;
}
.btn-disabled, .btn:disabled {
  background: #e9ecf1 !important; color: #a3adbb !important;
  border-color: #e3e7ed !important; cursor: not-allowed !important;
  box-shadow: none !important; opacity: 1 !important;
}
.btn-disabled:hover, .btn:disabled:hover { background: #e9ecf1 !important; color: #a3adbb !important; }

/* ===== 热搜词 ===== */
.hot-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; min-height: 24px; }
.hot-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.hot-item {
  font-size: 13px; color: #4a5568; background: #f5f7fa;
  padding: 3px 10px; border-radius: 999px; cursor: pointer; transition: .2s;
  text-decoration: none;   /* SSR 首页的热搜词是 <a>，去掉下划线 */
}
.hot-item:hover { background: #fff2ea; color: var(--primary); }
.hot-item.top { color: var(--primary); background: #fff2ea; font-weight: 600; }

/* ===== 搜索联想下拉 ===== */
.sug-box {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 50;
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .1); overflow: hidden; margin-top: 6px;
}
.sug-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; }
.sug-item:hover { background: #f7f9fc; }
.sug-item .sug-icon { flex: none; }
.sug-item .sug-text { flex: 1; font-size: 14px; color: #24303f; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sug-item .sug-type { flex: none; font-size: 12px; color: var(--muted); }

/* ===== 评论楼中楼 ===== */
.cmt-reply { margin: 8px 0 0 20px; padding-left: 12px; border-left: 2px solid #f0f2f5; }
.cmt-reply-item { padding: 6px 0; }
.cmt-name { font-size: 13px; font-weight: 600; }
.cmt-to { font-size: 12px; color: var(--muted); font-weight: 400; }
.cmt-text { font-size: 14px; margin: 5px 0; white-space: pre-wrap; }
.cmt-foot { font-size: 12px; color: var(--muted); }
.cmt-foot a { color: var(--primary); margin-left: 8px; }
.reply-tip { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ===== 卡片内操作区（一键复制等）===== */
.card-actions { margin-top: 10px; display: flex; gap: 8px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.ro-input:disabled { background: #f5f7fa; color: #a3adbb; cursor: not-allowed; }
.login-tip { color: var(--muted); font-size: 13px; margin-bottom: 14px; }

/* ===== 响应式：移动端（H5）===== */
@media (max-width: 640px) {
  .topbar-inner { gap: 10px; }
  .logo { font-size: 18px; }
  .search { order: 3; flex-basis: 100%; }
  .grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .card-cover { height: 110px; }
  .card-title { font-size: 14px; }
  .card-summary { -webkit-line-clamp: 2; }
  .row2 { grid-template-columns: 1fr; }
  .detail-title { font-size: 20px; }
}
@media (max-width: 380px) {
  .grid { grid-template-columns: 1fr; }
}
