/* ============================================================
   技术学习笔记 — 样式
   双主题，纯 CSS 变量驱动
   ============================================================ */

:root{
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", "SF Mono", "Menlo", Consolas, "Liberation Mono", monospace;
  --maxw: 760px;
  --r: 10px;
  --topbar-h: 58px;
  --side-w: 312px;
}

html[data-theme="light"]{
  --bg:#ffffff;
  --bg-soft:#f7f8fa;
  --bg-hover:#eef1f6;
  --bg-active:#e7edfa;
  --border:#e6e8ec;
  --border-strong:#d5d9e0;
  --text:#1f2328;
  --text-dim:#636b78;
  --text-faint:#9aa3b0;
  --accent:#2563eb;
  --accent-ink:#1d4ed8;
  --accent-soft:#eaf0ff;
  --code-bg:#f6f8fa;
  --code-border:#e6e8ec;
  --quote-bg:#f7f8fa;
  --mark:#fff3bf;
  --shadow:0 1px 2px rgba(16,24,40,.05), 0 6px 18px rgba(16,24,40,.05);
  --shadow-lg:0 8px 30px rgba(16,24,40,.10);
}
html[data-theme="dark"]{
  --bg:#0d1117;
  --bg-soft:#151a21;
  --bg-hover:#1c222b;
  --bg-active:#1e2733;
  --border:#242b35;
  --border-strong:#323b47;
  --text:#e6edf3;
  --text-dim:#98a3b0;
  --text-faint:#6e7781;
  --accent:#58a6ff;
  --accent-ink:#7cb8ff;
  --accent-soft:#172233;
  --code-bg:#161b22;
  --code-border:#2a313b;
  --quote-bg:#151a21;
  --mark:#4a3f1a;
  --shadow:0 1px 2px rgba(0,0,0,.35), 0 6px 18px rgba(0,0,0,.30);
  --shadow-lg:0 10px 34px rgba(0,0,0,.45);
}

*,*::before,*::after{ box-sizing:border-box; }

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

body{
  margin:0;
  font-family:var(--font-sans);
  font-size:15px;
  line-height:1.75;
  color:var(--text);
  background:var(--bg);
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
}

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

::selection{ background:var(--accent-soft); color:var(--text); }

/* 滚动条 */
::-webkit-scrollbar{ width:10px; height:10px; }
::-webkit-scrollbar-track{ background:transparent; }
::-webkit-scrollbar-thumb{ background:var(--border-strong); border-radius:10px; border:3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover{ background:var(--text-faint); }

/* ---------------- 阅读进度 ---------------- */
.progress{
  position:fixed; top:0; left:0; height:2px; width:0;
  background:linear-gradient(90deg,var(--accent),#8b5cf6);
  z-index:100; transition:width .08s linear;
}

/* ---------------- 顶栏 ---------------- */
.topbar{
  position:sticky; top:0; z-index:50;
  height:var(--topbar-h);
  display:flex; align-items:center; gap:12px;
  padding:0 18px;
  background:color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter:saturate(180%) blur(12px);
  -webkit-backdrop-filter:saturate(180%) blur(12px);
  border-bottom:1px solid var(--border);
}

.brand{
  display:flex; align-items:center; gap:10px;
  color:var(--text); flex:1; min-width:0;
}
.brand:hover{ text-decoration:none; }
.brand-mark{ font-size:19px; line-height:1; }
.brand-text{ display:flex; flex-direction:column; min-width:0; }
.brand-text strong{ font-size:15px; font-weight:650; letter-spacing:.2px; line-height:1.25; }
.brand-text em{ font-style:normal; font-size:11.5px; color:var(--text-faint); line-height:1.3; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

.topbar-actions{ display:flex; align-items:center; gap:8px; }

.search-mini{
  display:flex; align-items:center; gap:7px;
  padding:0 10px; height:34px; width:230px;
  background:var(--bg-soft);
  border:1px solid var(--border);
  border-radius:8px;
  color:var(--text-faint);
  transition:border-color .15s, box-shadow .15s, background .15s;
}
.search-mini:focus-within{
  border-color:var(--accent);
  background:var(--bg);
  box-shadow:0 0 0 3px var(--accent-soft);
}
.search-mini input{
  border:0; outline:0; background:transparent;
  width:100%; font:inherit; font-size:13.5px; color:var(--text);
}
.search-mini input::placeholder{ color:var(--text-faint); }

.icon-btn{
  display:inline-flex; align-items:center; justify-content:center;
  width:34px; height:34px; flex:none;
  border:1px solid var(--border); border-radius:8px;
  background:var(--bg-soft); color:var(--text-dim);
  cursor:pointer; transition:all .15s;
}
.icon-btn:hover{ color:var(--text); background:var(--bg-hover); border-color:var(--border-strong); }
.icon-btn:active{ transform:scale(.95); }

.ico-moon{ display:none; }
html[data-theme="dark"] .ico-sun{ display:none; }
html[data-theme="dark"] .ico-moon{ display:block; }

.only-mobile{ display:none; }

/* ---------------- 布局 ---------------- */
.layout{
  display:grid;
  grid-template-columns:var(--side-w) minmax(0,1fr);
  min-height:calc(100vh - var(--topbar-h));
}

/* ---------------- 侧栏 ---------------- */
.sidebar{
  position:sticky; top:var(--topbar-h);
  height:calc(100vh - var(--topbar-h));
  display:flex; flex-direction:column;
  border-right:1px solid var(--border);
  background:var(--bg-soft);
  overflow:hidden;
}

.side-search{
  position:relative;
  display:flex; align-items:center; gap:7px;
  margin:14px 14px 8px;
  padding:0 10px; height:36px;
  background:var(--bg);
  border:1px solid var(--border);
  border-radius:9px;
  color:var(--text-faint);
  transition:border-color .15s, box-shadow .15s;
}
.side-search:focus-within{ border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-soft); }
.side-search input{
  border:0; outline:0; background:transparent; width:100%;
  font:inherit; font-size:13.5px; color:var(--text);
}
.side-search input::placeholder{ color:var(--text-faint); }
.side-search input::-webkit-search-cancel-button{ display:none; }

.clear-btn{
  border:0; background:transparent; cursor:pointer;
  font-size:18px; line-height:1; color:var(--text-faint);
  padding:0 2px; border-radius:4px;
}
.clear-btn:hover{ color:var(--text); }

.tagbar{
  display:flex; flex-wrap:wrap; gap:6px;
  padding:2px 14px 12px;
}
.tag{
  font-size:11.5px; line-height:1;
  padding:5px 9px; border-radius:999px;
  border:1px solid var(--border);
  background:var(--bg); color:var(--text-dim);
  cursor:pointer; white-space:nowrap;
  transition:all .15s;
}
.tag:hover{ border-color:var(--border-strong); color:var(--text); }
.tag.on{
  background:var(--accent); border-color:var(--accent);
  color:#fff; font-weight:600;
}
html[data-theme="dark"] .tag.on{ color:#0d1117; }
.tag .n{ opacity:.6; margin-left:3px; font-size:10.5px; }
.tag.more{
  border-style:dashed;
  color:var(--text-faint);
  background:transparent;
}
.tag.more:hover{ color:var(--accent); border-color:var(--accent); }

.list-meta{
  display:flex; align-items:center; justify-content:space-between;
  padding:0 16px 8px;
  font-size:11.5px; color:var(--text-faint);
  border-bottom:1px solid var(--border);
}
.sort-toggle{ display:flex; gap:2px; }
.sort-toggle button{
  border:0; background:transparent; cursor:pointer;
  font:inherit; font-size:11.5px; color:var(--text-faint);
  padding:3px 7px; border-radius:5px;
}
.sort-toggle button:hover{ color:var(--text); background:var(--bg-hover); }
.sort-toggle button.on{ color:var(--accent); background:var(--accent-soft); font-weight:600; }

.note-list{ flex:1; overflow-y:auto; padding:6px 8px 20px; }

.note-item{
  display:block;
  padding:11px 12px;
  border-radius:9px;
  color:var(--text);
  cursor:pointer;
  border:1px solid transparent;
  transition:background .15s, border-color .15s;
}
.note-item:hover{ background:var(--bg-hover); text-decoration:none; }
.note-item.active{
  background:var(--bg-active);
  border-color:color-mix(in srgb, var(--accent) 35%, transparent);
}
.note-item.active .ni-title{ color:var(--accent); }

.ni-title{
  font-size:14px; font-weight:550; line-height:1.45;
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical;
  overflow:hidden; word-break:break-word;
}
.ni-sub{
  margin-top:5px;
  display:flex; align-items:center; gap:8px;
  font-size:11.5px; color:var(--text-faint);
}
.ni-sub .dot{ width:3px; height:3px; border-radius:50%; background:var(--text-faint); flex:none; }

.empty-list{
  padding:28px 16px; text-align:center;
  font-size:13px; color:var(--text-faint); line-height:1.8;
}

.side-foot{
  padding:9px 16px;
  border-top:1px solid var(--border);
  font-size:11px; color:var(--text-faint);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}

/* ---------------- 主区 ---------------- */
.main{ min-width:0; overflow-x:hidden; }
.main-inner{
  max-width:var(--maxw);
  margin:0 auto;
  padding:52px 32px 120px;
  animation:fade .28s ease both;
}
@keyframes fade{ from{ opacity:0; transform:translateY(6px); } to{ opacity:1; transform:none; } }

/* 欢迎页 */
.hero{ padding:34px 0 10px; }
.hero h1{ font-size:31px; line-height:1.3; margin:0 0 12px; letter-spacing:-.4px; }
.hero p{ color:var(--text-dim); font-size:15.5px; margin:0 0 30px; max-width:56ch; }
.hero-stats{
  display:grid; grid-template-columns:repeat(auto-fit,minmax(132px,1fr));
  gap:12px; margin-bottom:38px;
}
.stat{
  padding:16px 18px;
  background:var(--bg-soft);
  border:1px solid var(--border);
  border-radius:var(--r);
}
.stat b{ display:block; font-size:23px; font-weight:680; letter-spacing:-.5px; line-height:1.2; }
.stat span{ font-size:12px; color:var(--text-dim); }
.stat.accent b{ color:var(--accent); }

.sect-title{
  display:flex; align-items:center; gap:10px;
  font-size:12.5px; font-weight:650; letter-spacing:.08em;
  text-transform:uppercase; color:var(--text-faint);
  margin:0 0 14px;
}
.sect-title::after{ content:""; flex:1; height:1px; background:var(--border); }

.cards{ display:grid; gap:10px; margin-bottom:34px; }
.card{
  display:block; padding:16px 18px;
  border:1px solid var(--border); border-radius:var(--r);
  color:var(--text); background:var(--bg);
  cursor:pointer;
  transition:border-color .15s, transform .15s, box-shadow .15s;
}
.card:hover{ border-color:var(--border-strong); transform:translateY(-2px); box-shadow:var(--shadow); text-decoration:none; }
.card h3{ margin:0 0 6px; font-size:16.5px; font-weight:600; line-height:1.45; }
.card p{ margin:0; font-size:13.5px; color:var(--text-dim); line-height:1.65; }
.card .cfoot{ margin-top:10px; display:flex; align-items:center; gap:9px; font-size:11.5px; color:var(--text-faint); flex-wrap:wrap; }

.chip{
  font-size:11px; padding:2.5px 7px; border-radius:5px;
  background:var(--accent-soft); color:var(--accent-ink); font-weight:550;
}

/* ---------------- 文章 ---------------- */
.crumb{
  display:flex; align-items:center; gap:7px;
  font-size:12.5px; color:var(--text-faint);
  margin-bottom:22px;
}
.crumb a{ color:var(--text-dim); }
.crumb a:hover{ color:var(--accent); }

.article-head{ padding-bottom:22px; border-bottom:1px solid var(--border); margin-bottom:30px; }
.article-head h1{
  font-size:29px; line-height:1.35; letter-spacing:-.4px;
  margin:0 0 14px; font-weight:680;
}
.meta{
  display:flex; align-items:center; gap:9px; flex-wrap:wrap;
  font-size:12.5px; color:var(--text-faint);
}
.meta .msep{ width:1px; height:12px; background:var(--border-strong); }
.meta .mtags{ display:flex; gap:6px; flex-wrap:wrap; }

/* TOC */
.toc{
  margin:0 0 30px;
  border:1px solid var(--border);
  border-radius:var(--r);
  background:var(--bg-soft);
  overflow:hidden;
}
.toc summary{
  cursor:pointer; list-style:none;
  padding:11px 16px;
  font-size:12.5px; font-weight:620; color:var(--text-dim);
  display:flex; align-items:center; gap:8px;
  user-select:none;
}
.toc summary::-webkit-details-marker{ display:none; }
.toc summary::before{
  content:""; width:0; height:0; flex:none;
  border-left:5px solid var(--text-faint);
  border-top:4px solid transparent; border-bottom:4px solid transparent;
  transition:transform .15s;
}
.toc[open] summary::before{ transform:rotate(90deg); }
.toc summary:hover{ color:var(--text); }
.toc ol{
  margin:0; padding:2px 16px 14px 30px;
  font-size:13.5px; line-height:1.95;
}
.toc ol li{ color:var(--text-dim); }
.toc ol li a{ color:var(--text-dim); }
.toc ol li a:hover{ color:var(--accent); }
.toc .lv3{ padding-left:16px; font-size:13px; }

/* 正文排版 */
.prose{ font-size:15.5px; line-height:1.85; word-wrap:break-word; }
.prose > *:first-child{ margin-top:0; }

.prose h1,.prose h2,.prose h3,.prose h4{
  line-height:1.4; font-weight:650; letter-spacing:-.2px;
  margin:2.1em 0 .7em; scroll-margin-top:76px;
}
.prose h1{ font-size:24px; }
.prose h2{
  font-size:20px; padding-bottom:.35em;
  border-bottom:1px solid var(--border);
}
.prose h3{ font-size:17px; }
.prose h4{ font-size:15.5px; color:var(--text-dim); }

.anchor{
  margin-left:8px; font-size:.75em; color:var(--text-faint);
  opacity:0; transition:opacity .15s; text-decoration:none;
}
.prose h2:hover .anchor,
.prose h3:hover .anchor{ opacity:1; }

.prose p{ margin:0 0 1.1em; }
.prose strong{ font-weight:650; }
.prose em{ font-style:italic; }
.prose del{ color:var(--text-faint); }

.prose ul,.prose ol{ margin:0 0 1.15em; padding-left:1.5em; }
.prose li{ margin:.4em 0; }
.prose li::marker{ color:var(--text-faint); }
.prose ul{ list-style:disc; }
.prose ol{ list-style:decimal; }
.prose ul ul,.prose ol ol,.prose ul ol,.prose ol ul{ margin-bottom:0; }

/* 任务列表（- [ ] / - [x]） */
.prose li.task{
  list-style:none;
  display:flex; align-items:flex-start; gap:9px;
  margin-left:-1.15em;
}
.prose li.task input{
  flex:none; margin:0; position:relative; top:.42em;
  width:14px; height:14px;
  accent-color:var(--accent);
}
.prose li.task input:checked + span{ color:var(--text-faint); text-decoration:line-through; }

/* 复选框整体美化（含非任务列表） */
.prose input[type="checkbox"]{ accent-color:var(--accent); }

.prose blockquote{
  margin:0 0 1.2em; padding:2px 18px;
  border-left:3px solid var(--accent);
  background:var(--quote-bg);
  border-radius:0 8px 8px 0;
  color:var(--text-dim);
}
.prose blockquote p{ margin:.7em 0; }
.prose blockquote strong{ color:var(--text); }

.prose hr{ border:0; border-top:1px solid var(--border); margin:2.4em 0; }

.prose code{
  font-family:var(--font-mono);
  font-size:.875em;
  padding:.18em .42em;
  background:var(--code-bg);
  border:1px solid var(--code-border);
  border-radius:5px;
  word-break:break-word;
}

.prose pre{
  position:relative;
  margin:0 0 1.3em;
  background:var(--code-bg);
  border:1px solid var(--code-border);
  border-radius:var(--r);
  overflow:hidden;
}
.prose pre code{
  display:block;
  padding:16px 18px;
  background:none; border:0; border-radius:0;
  font-size:13px; line-height:1.72;
  overflow-x:auto;
  white-space:pre;
  tab-size:2;
}
.code-lang{
  position:absolute; top:0; right:0;
  padding:4px 10px;
  font-family:var(--font-mono); font-size:10.5px;
  color:var(--text-faint);
  background:var(--code-border);
  border-radius:0 var(--r) 0 8px;
  text-transform:lowercase; letter-spacing:.03em;
  pointer-events:none;
}
.copy-btn{
  position:absolute; top:7px; right:8px;
  display:inline-flex; align-items:center; gap:5px;
  padding:4px 9px;
  font-family:var(--font-sans); font-size:11.5px;
  color:var(--text-dim);
  background:var(--bg);
  border:1px solid var(--code-border);
  border-radius:6px;
  cursor:pointer; opacity:0;
  transition:opacity .15s, color .15s, border-color .15s;
}
.prose pre:hover .copy-btn{ opacity:1; }
.copy-btn:hover{ color:var(--accent); border-color:var(--accent); }
.copy-btn.done{ color:#16a34a; border-color:#16a34a; opacity:1; }

.prose table{
  width:100%; margin:0 0 1.3em;
  border-collapse:collapse;
  font-size:13.5px;
  display:block; overflow-x:auto;
}
.prose th,.prose td{
  padding:9px 13px;
  border:1px solid var(--border);
  text-align:left;
  vertical-align:top;
}
.prose th{ background:var(--bg-soft); font-weight:620; white-space:nowrap; }
.prose tbody tr:nth-child(even){ background:color-mix(in srgb, var(--bg-soft) 55%, transparent); }

.prose img{ max-width:100%; border-radius:var(--r); }

/* 行内高亮标记 */
.mark{
  padding:.1em .2em;
  border-radius:3px;
  background:var(--mark);
  color:inherit;
}
.prose mark{ background:var(--mark); color:inherit; padding:.1em .25em; border-radius:3px; }

/* 文章底部 */
.pager{
  display:grid; grid-template-columns:1fr 1fr; gap:12px;
  margin-top:52px; padding-top:26px; border-top:1px solid var(--border);
}
.pager a{
  display:block; padding:13px 16px;
  border:1px solid var(--border); border-radius:var(--r);
  color:var(--text); background:var(--bg);
  transition:border-color .15s, box-shadow .15s, transform .15s;
}
.pager a:hover{ border-color:var(--border-strong); box-shadow:var(--shadow); transform:translateY(-2px); text-decoration:none; }
.pager a.next{ text-align:right; }
.pager .pl{ display:block; font-size:11.5px; color:var(--text-faint); margin-bottom:4px; }
.pager .pt{ font-size:13.5px; font-weight:560; line-height:1.5; display:block; }
.pager .ph{ visibility:hidden; }

.article-foot{
  margin-top:26px;
  font-size:12.5px; color:var(--text-faint);
  text-align:center;
}

/* 搜索结果高亮 */
.search-hit{
  padding:24px 0 8px;
  font-size:13.5px; color:var(--text-dim);
  display:flex; align-items:center; justify-content:space-between; gap:12px;
}
.search-hit b{ color:var(--accent); font-weight:650; }

/* 搜索预览片段 */
.snippet{
  margin-top:6px;
  font-size:12px; line-height:1.6; color:var(--text-faint);
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;
}
.snippet mark{ background:var(--mark); color:var(--text); border-radius:3px; padding:0 2px; }

/* 遮罩 */
.scrim{
  position:fixed; inset:0; z-index:38;
  background:rgba(0,0,0,.42);
  opacity:0; pointer-events:none; transition:opacity .22s;
}
.scrim.on{ opacity:1; pointer-events:auto; }

/* ---------------- 响应式 ---------------- */
@media (max-width:1080px){
  :root{ --side-w:272px; }
  .main-inner{ padding:40px 26px 100px; }
}

@media (max-width:820px){
  .search-mini{ width:150px; }
  .layout{ grid-template-columns:1fr; }
  .only-mobile{ display:inline-flex; }
  .sidebar{
    position:fixed; top:var(--topbar-h); left:0; z-index:40;
    width:min(84vw,320px);
    transform:translateX(-100%);
    transition:transform .24s cubic-bezier(.4,0,.2,1);
    box-shadow:var(--shadow-lg);
  }
  .sidebar.open{ transform:none; }
  .main-inner{ padding:28px 18px 90px; }
  .brand-text em{ display:none; }
  .hero h1{ font-size:26px; }
  .article-head h1{ font-size:23px; }
  .prose{ font-size:15px; }
  .pager{ grid-template-columns:1fr; }
  .copy-btn{ opacity:1; }
}

@media (max-width:520px){
  .search-mini{ display:none; }
  .hero-stats{ grid-template-columns:repeat(2,1fr); }
  .topbar{ padding:0 12px; gap:8px; }
}

/* 打印 */
@media print{
  .topbar,.sidebar,.pager,.toc,.progress,.copy-btn,.anchor{ display:none !important; }
  .main-inner{ max-width:none; padding:0; }
  .prose pre{ white-space:pre-wrap; }
}
