/* ===== 认知大本营 · 学习站 — Beszel 风浅色主题 v2 ===== */
:root {
  --bg: #f4f6f9;
  --bg-grad-a: rgba(34, 211, 238, .10);
  --bg-grad-b: rgba(129, 140, 248, .08);
  --card: #ffffff;
  --card-hover: #fbfdff;
  --line: #e6ebf2;
  --line-soft: #eef2f7;
  --text: #18212f;
  --text-dim: #52657a;
  --text-faint: #93a4b8;
  --cyan: #06b6d4;
  --teal: #10b981;
  --blue: #3b82f6;
  --green: #10b981;
  --indigo: #6366f1;
  --amber: #f59e0b;
  --rose: #f43f5e;
  --purple: #8b5cf6;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(23, 33, 48, .05), 0 8px 24px rgba(23, 33, 48, .07);
  --shadow-hover: 0 2px 6px rgba(23, 33, 48, .06), 0 14px 34px rgba(23, 33, 48, .10);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(900px 420px at 88% -8%, var(--bg-grad-a), transparent 55%),
    radial-gradient(760px 400px at -6% 12%, var(--bg-grad-b), transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Segoe UI", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.app { max-width: 760px; margin: 0 auto; padding: 0 16px calc(28px + var(--safe-b)); }

/* ---- 顶栏 ---- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 20px 0 8px; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 42px; height: 42px; border-radius: 13px; flex: none;
  background: linear-gradient(135deg, #06b6d4, #6366f1 70%);
  box-shadow: 0 6px 16px rgba(99, 102, 241, .32), inset 0 0 0 1px rgba(255, 255, 255, .25);
  position: relative;
}
.logo::before { /* 星形 */
  content: ""; position: absolute; left: 50%; top: 42%; width: 15px; height: 15px;
  transform: translate(-50%, -50%);
  background: #fff;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.logo::after { /* 三条知识线 */
  content: ""; position: absolute; left: 50%; top: 78%; width: 22px; height: 2.5px; transform: translateX(-50%);
  border-radius: 2px; background: rgba(255, 255, 255, .92);
  box-shadow: 0 6px 0 rgba(255, 255, 255, .55), 0 -6px 0 rgba(255, 255, 255, .4);
}
.brand-text h1 { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: .3px; color: #101a2b; }
.brand-text .sub { margin: 1px 0 0; font-size: 12px; color: var(--text-faint); font-weight: 500; }
.top-actions { display: flex; gap: 8px; }

/* ---- 按钮 ---- */
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--text-dim); font-size: 16px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 2px rgba(23, 33, 48, .04); transition: all .18s;
}
.icon-btn:hover { background: #fff; color: var(--text); transform: translateY(-1px); box-shadow: var(--shadow); }
.icon-btn:active { transform: scale(.94); }
.btn {
  border: 1px solid var(--line); border-radius: 11px; padding: 9px 14px; cursor: pointer;
  font-size: 13.5px; color: var(--text-dim); background: var(--card); transition: all .18s;
  display: inline-flex; align-items: center; gap: 6px; font-weight: 600;
  box-shadow: 0 1px 2px rgba(23, 33, 48, .04);
}
.btn:hover { background: #fff; color: var(--text); box-shadow: var(--shadow); }
.btn:active { transform: scale(.96); }
.btn.ghost { border-style: dashed; }
.btn.ghost:hover { border-color: rgba(6, 182, 212, .6); color: #0e7490; }
.btn.loading { opacity: .6; pointer-events: none; }

/* ---- 工具条 / 搜索 ---- */
.toolbar { display: flex; align-items: center; gap: 8px; margin: 16px 0 10px; flex-wrap: wrap; }
.offline-state { font-size: 12px; color: var(--green); font-weight: 600; margin-left: 2px; }
.offline-state.off { color: var(--rose); }
.searchbar { position: relative; margin: 6px 0 12px; }
.searchbar input {
  width: 100%; padding: 11px 40px 11px 40px; border-radius: 14px;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  font-size: 14.5px; outline: none; transition: border .2s, box-shadow .2s;
  box-shadow: 0 1px 2px rgba(23, 33, 48, .04);
}
.searchbar input:focus { border-color: rgba(6, 182, 212, .6); box-shadow: 0 0 0 3.5px rgba(6, 182, 212, .14); }
.searchbar input::placeholder { color: var(--text-faint); }
.search-ic { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; border: 2px solid var(--text-faint); border-radius: 50%; }
.search-ic::after { content: ""; position: absolute; width: 2px; height: 6.5px; background: var(--text-faint); transform: rotate(-45deg); right: -3.5px; bottom: -3.5px; border-radius: 2px; }
.search-clear { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--text-faint); font-size: 18px; cursor: pointer; width: 26px; height: 26px; border-radius: 8px; }
.search-clear:hover { background: var(--line-soft); color: var(--text-dim); }

/* ---- 分类胶囊 ---- */
.cats { display: flex; gap: 8px; overflow-x: auto; padding: 6px 2px 14px; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); border-radius: 999px; padding: 7px 13px;
  background: var(--card); color: var(--text-dim); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all .18s; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  box-shadow: 0 1px 2px rgba(23, 33, 48, .04);
}
.chip .n { font-size: 11px; background: rgba(23, 33, 48, .06); padding: 1px 7px; border-radius: 99px; }
.chip:hover { color: var(--text); border-color: #d6dee9; }
.chip.active {
  color: #fff; border: 1px solid transparent;
  background: linear-gradient(135deg, #06b6d4, #6366f1);
  box-shadow: 0 4px 12px rgba(99, 102, 241, .28);
}
.chip.active .n { background: rgba(255, 255, 255, .24); }

/* ---- 列表卡片 ---- */
.list { display: flex; flex-direction: column; gap: 10px; }
.card {
  display: block; text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 15px; cursor: pointer; transition: all .18s; position: relative; overflow: hidden;
  box-shadow: 0 1px 2px rgba(23, 33, 48, .04);
}
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent, var(--cyan)); border-radius: 0 4px 4px 0; }
.card:hover { background: var(--card-hover); border-color: #d8e0eb; transform: translateY(-1.5px); box-shadow: var(--shadow-hover); }
.card:active { transform: scale(.985); }
.card-head { display: flex; align-items: center; gap: 12px; }
.card-emoji {
  width: 42px; height: 42px; border-radius: 13px; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 21px; color: #fff;
  background: var(--grad, linear-gradient(135deg, #06b6d4, #6366f1));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .28), 0 4px 10px rgba(23, 33, 48, .12);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .08);
}
.card-main { flex: 1; min-width: 0; }
.card-title { font-size: 15px; font-weight: 650; line-height: 1.45; margin: 0; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { display: flex; align-items: center; gap: 8px; margin-top: 7px; font-size: 12px; color: var(--text-faint); }
.catname { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--accent, var(--cyan)); font-size: 12px; }
.tag {
  font-size: 11px; font-weight: 600; border-radius: 7px; padding: 1.5px 8px;
  border: 1px solid var(--line); color: var(--text-dim); background: var(--line-soft);
}
.empty { text-align: center; padding: 46px 0; color: var(--text-faint); font-size: 14px; }
.footnote { text-align: center; color: var(--text-faint); font-size: 12px; margin: 22px 0 6px; }

/* ---- 骨架屏 ---- */
.skeleton { display: flex; flex-direction: column; gap: 10px; }
.sk-card { height: 78px; border-radius: var(--radius); border: 1px solid var(--line-soft); background: linear-gradient(100deg, #f1f4f9 40%, #e7ecf3 50%, #f1f4f9 60%); background-size: 200% 100%; animation: sk 1.3s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---- 视图切换 ---- */
.view { display: none; }
.view.active { display: block; animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.flex-sp { flex: 1; }

/* ---- 阅读页 ---- */
.reader-top { display: flex; align-items: center; gap: 10px; padding: 16px 0 10px; position: sticky; top: 0; z-index: 5; background: linear-gradient(var(--bg) 82%, transparent); }
.reader-crumb { font-size: 13px; color: var(--text-faint); font-weight: 600; }
.article { padding-bottom: 40px; }
.article-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow); padding: 22px 20px 24px; margin-top: 6px;
}
.article-head { margin: 0 0 4px; }
.article-head .chips { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.article-head .tag { background: none; border-color: currentColor; padding: 3px 10px; font-size: 12px; }
.article h1.article-title { font-size: 22px; line-height: 1.42; margin: 0; font-weight: 800; letter-spacing: .2px; color: #101a2b; }
.article .md-body { font-size: 15.5px; color: #2c3a4c; word-break: break-word; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4 { line-height: 1.45; margin: 1.5em 0 .6em; font-weight: 800; color: #15202f; }
.md-body h1 { font-size: 20px; }
.md-body h2 { font-size: 18px; padding-left: 11px; border-left: 4px solid var(--cyan); }
.md-body h3 { font-size: 16.5px; }
.md-body p { margin: .85em 0; }
.md-body ul, .md-body ol { padding-left: 1.4em; margin: .8em 0; }
.md-body li { margin: .3em 0; }
.md-body li::marker { color: var(--teal); }
.md-body strong { color: #101a2b; font-weight: 750; }
.md-body blockquote {
  margin: 1em 0; padding: 11px 15px; border-left: 4px solid var(--teal);
  background: #ecfdf5; border-radius: 0 12px 12px 0; color: #14532d;
}
.md-body blockquote p { margin: .3em 0; }
.md-body code {
  background: #eef3f8; padding: 1.5px 6px; border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; color: #0f766e;
}
.md-body pre { background: #0f1b2d; color: #d7e2ee; padding: 13px 15px; border-radius: 13px; overflow-x: auto; }
.md-body pre code { background: none; color: inherit; }
.md-body a { color: #0891b2; text-decoration: none; border-bottom: 1px dashed rgba(8, 145, 178, .55); font-weight: 500; }
.md-body hr { border: 0; height: 1px; background: var(--line); margin: 1.6em 0; }
.md-body table { border-collapse: collapse; width: 100%; margin: 1em 0; font-size: 14px; }
.md-body th, .md-body td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; }
.md-body th { background: #f4f7fa; }
.article-foot { margin-top: 22px; padding-top: 14px; border-top: 1px dashed var(--line); font-size: 12px; color: var(--text-faint); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.article-foot .act { display: inline-flex; gap: 8px; }
.article-foot button { background: none; border: 0; color: var(--text-dim); font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 5px 9px; border-radius: 9px; }
.article-foot button:hover { background: var(--line-soft); color: var(--text); }

/* ---- Toast ---- */
.toast {
  position: fixed; left: 50%; bottom: calc(26px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
  background: #101a2b; color: #fff;
  padding: 11px 20px; border-radius: 13px; font-size: 13.5px;
  box-shadow: 0 12px 30px rgba(16, 26, 43, .28); opacity: 0; pointer-events: none;
  transition: all .28s; z-index: 99; max-width: 86vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- 安装引导 ---- */
.install-sheet {
  position: fixed; inset: auto 0 0 0; z-index: 60; background: #fff;
  border-radius: 22px 22px 0 0; border: 1px solid var(--line); padding: 24px 20px calc(20px + var(--safe-b));
  box-shadow: 0 -12px 44px rgba(16, 26, 43, .18); animation: up .28s ease; max-width: 760px; margin: 0 auto;
}
@keyframes up { from { transform: translateY(60px); opacity: 0; } to { transform: none; opacity: 1; } }
.install-sheet h3 { margin: 0 0 6px; font-size: 17px; color: #101a2b; }
.install-sheet p { margin: 0 0 16px; color: var(--text-dim); font-size: 13.5px; line-height: 1.6; }
.install-sheet .row { display: flex; gap: 10px; }
.install-sheet .btn { flex: 1; justify-content: center; padding: 12px; font-size: 15px; }
.install-sheet .btn.primary {
  background: linear-gradient(135deg, #06b6d4, #6366f1); color: #fff; border: 0;
  box-shadow: 0 6px 16px rgba(99, 102, 241, .3);
}
.hide { display: none !important; }
