:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #e4e7ec;
  --text: #1b1f24;
  --muted: #6b7280;
  --accent: #8b5cf6;
  --accent-2: #6d5ae0;
  --accent-soft: #f1ecff;
  --danger: #e5484d;
  --ok: #0ca678;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.06);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
body { display: flex; flex-direction: column; }
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }
.grow { flex: 1; }

/* ---------- 顶栏 ---------- */
.topbar {
  height: 54px; flex: 0 0 54px; display: flex; align-items: center; gap: 10px;
  padding: 0 12px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: relative; z-index: 20;
  padding-top: env(safe-area-inset-top);
}
.brand { font-weight: 800; font-size: 16px; letter-spacing: .2px; white-space: nowrap; }
.brand span { color: var(--accent); }
.tb-search {
  flex: 1; display: flex; align-items: center; gap: 6px;
  border: none; background: var(--bg); border-radius: 999px;
  padding: 8px 12px; font-size: 13px; color: #9aa1ab; min-width: 0;
}
.tb-search:active { background: var(--accent-soft); }
.tb-search-ico { font-size: 13px; }
.tb-search-ph { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tb-btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 10px; padding: 7px 9px; font-size: 15px;
}

/* ---------- 页面 ---------- */
.page { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 76px; }

/* ---------- 未解锁引导 ---------- */
.gate { max-width: 620px; margin: 0 auto; padding: 26px 18px 20px; }
.gate-hero { text-align: center; }
.gate-emoji {
  width: 84px; height: 84px; margin: 0 auto 14px; border-radius: 26px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-size: 42px; line-height: 84px;
  box-shadow: 0 10px 30px rgba(139,92,246,.35);
}
.gate-hero h1 { font-size: 22px; margin: 0 0 8px; }
.gate-sub { color: var(--muted); font-size: 13.5px; line-height: 1.8; margin: 0; }
.gate-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 6px 16px; margin: 20px 0 14px; box-shadow: var(--shadow);
}
.gate-feat { display: flex; flex-direction: column; gap: 3px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.gate-feat:last-child { border-bottom: none; }
.gate-feat b { font-size: 14px; }
.gate-feat span { font-size: 12.5px; color: var(--muted); }
.gate-interest { margin-bottom: 16px; }
.gate-i-title { font-size: 13.5px; font-weight: 700; margin-bottom: 10px; }
.gate-tip { text-align: center; color: #b0b6bf; font-size: 12px; margin: 10px 0 0; }
.gen-btn {
  width: 100%; padding: 14px 0; border: none; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 15.5px; font-weight: 700; letter-spacing: 1px;
  box-shadow: 0 6px 18px rgba(139,92,246,.35);
}
.gen-btn:active { transform: scale(.985); }

/* ---------- 分类条 ---------- */
.cat-bar {
  display: flex; gap: 8px; overflow-x: auto; padding: 10px 12px 6px;
  scrollbar-width: none; max-width: 620px; margin: 0 auto;
}
.cat-bar::-webkit-scrollbar { display: none; }
.cat {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  border-radius: 999px; padding: 6px 14px; font-size: 12.5px; font-weight: 600;
}
.cat.on { border-color: transparent; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }

/* ---------- 瀑布流 ---------- */
.waterfall {
  column-count: 2; column-gap: 10px; max-width: 620px; margin: 0 auto; padding: 8px 12px 4px;
}
.note-card {
  break-inside: avoid; margin-bottom: 10px; background: var(--panel);
  border-radius: 14px; overflow: hidden; border: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(16,24,40,.05); cursor: pointer;
}
.note-card:active { transform: scale(.985); }
.nc-cover {
  display: flex; align-items: center; justify-content: center;
  font-size: 52px; min-height: 130px; position: relative; padding: 22px 10px;
  text-align: center; line-height: 1.2;
}
.nc-body { padding: 10px 12px 12px; }
.nc-title {
  font-size: 13.8px; font-weight: 700; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.nc-foot { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.nc-author { flex: 1; font-size: 11.5px; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.nc-like { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.nc-like.liked { color: #ff2e4d; font-weight: 700; }
.feed-empty { text-align: center; color: var(--muted); font-size: 13px; padding: 30px 20px; line-height: 1.8; }
.more-btn {
  display: block; width: calc(100% - 24px); max-width: 596px; margin: 6px auto 20px;
  padding: 12px 0; border-radius: 12px; font-size: 14px; font-weight: 700;
  border: 1px dashed #cfc6f2; background: var(--panel); color: var(--accent);
}
.more-btn:active { background: var(--accent-soft); }

/* ---------- 搜索页 ---------- */
#pageSearch { padding-top: 10px; }
.search-row { display: flex; gap: 8px; padding: 0 12px; max-width: 620px; margin: 0 auto; }
#searchInput {
  flex: 1; border: none; background: var(--panel); border-radius: 999px;
  padding: 11px 16px; font-size: 13.5px; outline: none; color: var(--text);
  border: 1px solid var(--line); min-width: 0;
}
#searchInput:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-go {
  border: none; border-radius: 999px; padding: 0 18px; font-size: 13.5px; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  box-shadow: 0 4px 12px rgba(139,92,246,.3);
}
.search-idle { text-align: center; padding: 40px 28px; color: var(--muted); }
.si-emoji { font-size: 44px; margin-bottom: 12px; }
.search-idle p { font-size: 13px; line-height: 1.9; margin: 0 0 18px; }
.si-try { font-size: 12.5px; margin-bottom: 10px; color: #9aa1ab; }
.search-hist { max-width: 620px; margin: 0 auto; padding: 6px 12px 0; }
.search-opti {
  max-width: 620px; margin: 10px auto 0; background: var(--accent-soft);
  border-radius: 12px; padding: 10px 14px; font-size: 12.5px; line-height: 1.8; color: #4c3d8f;
}
.search-opti b { color: var(--accent-2); }
.search-opti .kw { display: inline-block; background: #fff; border-radius: 999px; padding: 2px 10px; margin: 2px 4px 0 0; font-size: 12px; color: var(--accent-2); cursor: pointer; }

/* ---------- 我的 ---------- */
#pageMine { max-width: 620px; margin: 0 auto; padding: 16px 16px 20px; }
.mine-head {
  display: flex; align-items: center; gap: 12px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px; padding: 14px; box-shadow: var(--shadow);
}
.mine-avatar {
  width: 54px; height: 54px; border-radius: 50%; font-size: 28px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
}
.mine-info { flex: 1; min-width: 0; }
.mine-info b { font-size: 15.5px; display: block; }
.mine-info span { font-size: 12px; color: var(--ok); }
.mine-badge {
  font-size: 11px; color: var(--accent); background: var(--accent-soft);
  border-radius: 999px; padding: 5px 10px; white-space: nowrap;
}
.mine-sec { margin-top: 16px; }
.mine-title { font-weight: 700; font-size: 14px; margin-bottom: 10px; }
.mine-tip { font-size: 11.5px; color: #b0b6bf; font-weight: 400; margin-left: 6px; }
.mine-item {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 14px; font-size: 13.5px; font-weight: 600; margin-bottom: 8px; color: var(--text);
}
.mine-item:active { background: var(--bg); }
.mi-val { font-size: 12px; color: var(--muted); font-weight: 400; }
.mi-val.ok { color: var(--ok); }
.fav-list { display: flex; flex-direction: column; gap: 8px; }
.fav-item {
  display: flex; align-items: center; gap: 10px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer;
}
.fav-item:active { background: var(--bg); }
.fav-emoji {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 10px; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
}
.fav-info { flex: 1; min-width: 0; }
.fav-info b { font-size: 13px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fav-info span { font-size: 11.5px; color: var(--muted); }
.fav-x { border: none; background: none; color: #b0b6bf; font-size: 15px; padding: 6px; }
.fav-empty { color: #b0b6bf; font-size: 12.5px; padding: 6px 2px; }
.mine-foot { text-align: center; color: #b0b6bf; font-size: 11.5px; line-height: 1.9; margin-top: 22px; }

/* ---------- chips ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  border-radius: 999px; padding: 7px 13px; font-size: 12.5px; font-weight: 600;
}
.chip.on { border-color: transparent; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 3px 10px rgba(139,92,246,.3); }

/* ---------- 底部导航 ---------- */
.tabbar {
  flex: 0 0 auto; display: flex; background: var(--panel);
  border-top: 1px solid var(--line); padding: 6px 0 calc(8px + env(safe-area-inset-bottom));
  position: relative; z-index: 30;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: none; background: none; color: #9aa1ab; font-size: 10.5px; font-weight: 600;
  padding: 4px 0;
}
.tab-ico { font-size: 21px; filter: grayscale(1) opacity(.55); }
.tab.on { color: var(--accent); }
.tab.on .tab-ico { filter: none; }

/* ---------- 笔记详情 ---------- */
.note-layer { align-items: flex-end; }
.note-sheet {
  width: 100%; height: 92vh; background: var(--panel); border-radius: 18px 18px 0 0;
  display: flex; flex-direction: column; position: relative; animation: slideUp .25s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: .6; } }
.note-close {
  position: absolute; top: 12px; right: 12px; z-index: 5;
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: rgba(0,0,0,.35); color: #fff; font-size: 14px;
}
.note-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.nt-cover {
  min-height: 150px; display: flex; align-items: center; justify-content: center;
  font-size: 64px; padding: 26px 24px; text-align: center; line-height: 1.2;
}
.nt-body { padding: 18px 18px 24px; }
.nt-title { font-size: 19px; font-weight: 800; line-height: 1.5; margin: 0 0 10px; }
.nt-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.nt-avatar {
  width: 30px; height: 30px; border-radius: 50%; font-size: 15px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
}
.nt-author { font-size: 12.5px; color: var(--muted); flex: 1; }
.nt-tag {
  display: inline-block; font-size: 11.5px; color: var(--accent);
  background: var(--accent-soft); border-radius: 999px; padding: 3px 10px; margin: 0 6px 6px 0;
}
.nt-content { font-size: 14.5px; line-height: 1.95; white-space: pre-wrap; word-break: break-word; }
.nt-deep {
  margin-top: 18px; border-top: 1px dashed #d9d2f5; padding-top: 14px;
}
.nt-deep-title { font-size: 13px; font-weight: 800; color: var(--accent-2); margin-bottom: 8px; }
.nt-deep .nt-content { font-size: 13.5px; }
.nt-deep .loading { padding: 10px 0; }
.note-acts {
  flex: 0 0 auto; display: flex; gap: 8px; padding: 10px 14px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--panel);
}
.act {
  flex: 1; padding: 12px 0; border-radius: 12px; font-size: 13px; font-weight: 700;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
}
.act:active { background: var(--bg); }
.act.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border: none; }

/* ---------- loading / 弹层 / 设置 ---------- */
.loading { text-align: center; padding: 40px 0 30px; }
.spinner {
  width: 40px; height: 40px; margin: 0 auto 14px; border-radius: 50%;
  border: 3.5px solid var(--accent-soft); border-top-color: var(--accent);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading > div:last-child { color: var(--muted); font-size: 13px; }

.layer {
  position: fixed; inset: 0; z-index: 100; background: rgba(15,17,21,.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 560px; background: var(--panel);
  border-radius: 18px 18px 0 0; padding: 14px 16px 30px;
  max-height: 86vh; overflow-y: auto;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sheet-head b { font-size: 15.5px; }
.link-btn { border: none; background: none; color: var(--accent); font-size: 13px; font-weight: 600; padding: 6px 4px; }

.set-sec { border-top: 1px solid var(--line); padding: 14px 0 6px; }
.set-sec:first-of-type { border-top: none; }
.set-title { font-weight: 700; font-size: 14px; margin-bottom: 10px; }
.key-state { float: right; font-size: 12px; font-weight: 600; color: var(--muted); }
.key-state.ok { color: var(--ok); }
.set-sec input, .set-sec select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; font-size: 13px; background: var(--panel); color: var(--text); outline: none;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.set-sec input:focus, .set-sec select:focus { border-color: var(--accent); }
.set-btns { display: flex; gap: 10px; margin-top: 10px; }
.btn { flex: 1; padding: 11px 0; border-radius: 10px; font-size: 13.5px; font-weight: 600; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border: none; }
.btn.danger { color: var(--danger); }
.set-msg { font-size: 12.5px; margin: 8px 0 0; line-height: 1.6; word-break: break-all; }
.set-msg.ok { color: var(--ok); }
.set-msg.err { color: var(--danger); }
.set-tip { font-size: 12px; color: var(--muted); margin: 8px 0 0; line-height: 1.6; }

/* ---------- 安装引导 ---------- */
.inst-body { padding: 4px 0; }
.inst-steps { font-size: 13.5px; line-height: 1.9; color: var(--text); }
.inst-steps b { color: var(--accent); }
.inst-qr { text-align: center; margin: 14px 0; }
.inst-qr img { width: 148px; height: 148px; border-radius: 10px; }
.inst-qr-tip { font-size: 12px; color: var(--muted); margin-top: 8px; }
.inst-profile { margin-top: 12px; }
.inst-profile .btn { width: 100%; margin-bottom: 8px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%);
  background: rgba(20,22,28,.92); color: #fff; font-size: 13px; line-height: 1.6;
  padding: 10px 18px; border-radius: 999px; max-width: 84vw; text-align: center;
  z-index: 300; animation: fadeUp .25s ease;
}
.toast.err { background: var(--danger); }
@keyframes fadeUp { from { opacity: 0; transform: translate(-50%, 8px); } }

@media (min-width: 640px) {
  .layer { align-items: center; }
  .sheet { border-radius: 18px; margin-bottom: 6vh; }
  .note-layer { align-items: center; }
  .note-sheet { height: 82vh; max-width: 620px; border-radius: 18px; }
}

/* ---------- 真实小红书跳转卡 ---------- */
.real-bar {
  max-width: 620px; margin: 10px auto 0; padding: 12px 14px;
  background: linear-gradient(135deg, #fff1f3, #f6efff);
  border: 1px solid #f2dbe3; border-radius: 14px;
}
.real-title { font-size: 13px; font-weight: 800; margin-bottom: 8px; color: #b02a3c; }
.real-kw {
  font-size: 13px; line-height: 1.55; color: #6d3a52; background: #fff;
  border-radius: 9px; padding: 9px 11px; word-break: break-all;
  border: 1px dashed #f3cfd9;
}
.real-btns { display: flex; gap: 8px; margin-top: 10px; }
.rb {
  flex: 1; padding: 12px 0; border-radius: 10px; font-size: 13.5px; font-weight: 800;
  border: 1px solid var(--line); background: #fff; color: var(--text);
}
.rb.xhs {
  border: none; color: #fff; background: linear-gradient(135deg, #ff2442, #ff5a76);
  box-shadow: 0 5px 14px rgba(255,36,66,.28);
}
.rb:active { transform: scale(.985); }
.real-tip { font-size: 11.5px; color: #9b7b86; line-height: 1.6; margin: 8px 0 0; }
.ai-head {
  max-width: 620px; margin: 16px auto 2px; padding: 0 12px;
  display: flex; align-items: center; gap: 8px;
}
.ai-head b { font-size: 13.5px; }
.ai-head span { font-size: 11.5px; color: #b0b6bf; }
.gate-link {
  display: block; width: 100%; margin-top: 10px; padding: 12px 0;
  border: none; background: none; color: #b02a3c; font-size: 13.5px; font-weight: 700;
}
.gate-link:active { opacity: .65; }

/* ---------- 真实小红书入口强化 ---------- */
.feed-hint {
  max-width: 620px; margin: 2px auto 0; padding: 0 14px 4px;
  font-size: 11.5px; color: #9aa1ab; line-height: 1.6;
}
.act.xhs {
  border: none; color: #fff; background: linear-gradient(135deg, #ff2442, #ff5a76);
  box-shadow: 0 4px 12px rgba(255,36,66,.28);
  flex: 1.4;
}
.jump-inline {
  display: block; width: 100%; margin: 0 0 16px; padding: 13px 14px;
  border: none; border-radius: 12px; text-align: left;
  background: linear-gradient(135deg, #ff2442, #ff5a76); color: #fff;
  font-size: 14px; font-weight: 800; line-height: 1.5;
  box-shadow: 0 6px 16px rgba(255,36,66,.25);
}
.jump-inline:active { transform: scale(.99); }
.nt-badge {
  display: inline-block; font-size: 11px; font-weight: 700; color: #8a6d7a;
  background: #fdf0f3; border: 1px solid #f3dbe2; border-radius: 999px;
  padding: 3px 10px; margin-bottom: 10px;
}
.nc-jump { font-size: 11.5px; color: #ff2442; font-weight: 700; white-space: nowrap; }
.tb-xhs {
  background: linear-gradient(135deg, #ff2442, #ff5a76); color: #fff;
  border: none; font-size: 15px; padding: 7px 10px;
  box-shadow: 0 3px 10px rgba(255,36,66,.3);
}
.tb-xhs { font-size: 12px; letter-spacing: .5px; padding: 7px 11px; }
@media (max-width: 430px) {
  .brand { font-size: 14.5px; }
  .tb-search-ph { display: none; }
  .tb-search { flex: 0 0 auto; padding: 8px 11px; }
  .topbar { gap: 7px; padding: 0 9px; }
  .tb-search { margin-left: auto; }
}

/* ---------- 跳转兜底面板 ---------- */
.jump-fall {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  width: min(92vw, 380px); z-index: 260; padding: 14px;
  background: #fff; border-radius: 16px; border: 1px solid #f2dbe3;
  box-shadow: 0 14px 40px rgba(16,24,40,.18); animation: fadeUp .2s ease;
}
.jf-t { font-size: 13px; font-weight: 800; color: #b02a3c; margin-bottom: 6px; }
.jf-kw { font-size: 12px; color: #9b7b86; margin-bottom: 10px; }
.jf-a {
  display: block; text-align: center; text-decoration: none;
  padding: 12px 0; border-radius: 10px; color: #fff; font-size: 13.5px; font-weight: 800;
  background: linear-gradient(135deg, #ff2442, #ff5a76);
}
.jf-c {
  display: block; width: 100%; margin-top: 8px; padding: 9px 0;
  border: none; background: none; color: #9aa1ab; font-size: 12.5px;
}

/* ---------- 微信提示条 / 安装按钮 ---------- */
.wx-bar {
  flex: 0 0 auto; display: flex; flex-direction: column; gap: 2px;
  padding: 9px 14px; background: #fff7e6; border-bottom: 1px solid #ffe0a3;
  font-size: 11.5px; line-height: 1.5; color: #8a5a00; z-index: 21;
}
.wx-bar b { font-size: 12px; color: #b45309; }
.gate-install {
  display: block; width: 100%; margin-top: 10px; padding: 14px 0;
  border-radius: 12px; border: 1.5px solid #ffd0d9; background: #fff;
  color: #ff2442; font-size: 14.5px; font-weight: 800;
}
.gate-install:active { transform: scale(.985); background: #fff5f7; }
.ji-sub { display: block; font-size: 11.5px; font-weight: 500; opacity: .88; margin-top: 3px; }
.copy-kw {
  display: block; width: 100%; margin: -8px 0 16px; padding: 10px 0;
  border: 1px dashed #f3cfd9; border-radius: 10px; background: #fffafb;
  color: #a8556b; font-size: 12.5px; font-weight: 600;
}
.copy-kw:active { background: #fff1f5; }
