/* ==========================================================================
   个人网站 · 样式表
   设计参考：DeepSeek 网页版聊天界面（浅色主题）
   - 左侧：会话列表式目录（可折叠）
   - 中间：聊天消息流式的正文
   - 右侧：当前页面的小目录（TOC）
   ========================================================================== */

:root {
  /* 取自 DeepSeek 网页版观感 */
  --bg-side: #f9fbff;
  --bg-main: #ffffff;
  --bg-soft: #f5f7fb;
  --bg-code: #f6f8fa;

  --line: #e8ecf3;
  --line-strong: #dde3ee;

  --text: #1b1c1e;
  --text-2: #4a4f57;
  --text-3: #8b909a;

  --brand: #4d6bfe;
  --brand-soft: #eef2ff;
  --brand-deep: #3a55e0;

  --amber: #b7791f;
  --amber-soft: #fff8e6;
  --amber-line: #f0dfae;

  --radius: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(21, 32, 66, .05);
  --shadow-md: 0 6px 20px rgba(21, 32, 66, .07);

  --side-w: 268px;
  --toc-w: 228px;
  --gutter: 34px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg-main);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei UI",
               "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", Roboto, sans-serif;
  font-size: 15.5px;
  line-height: 1.78;
  -webkit-font-smoothing: antialiased;
}

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

::selection { background: #d7e0ff; }

/* ---------- 滚动条（细，浅色） ---------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb {
  background: #d9dee8; border-radius: 999px;
  border: 2px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: #c3cad8; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ==========================================================================
   1. 布局
   ========================================================================== */

.layout {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr) var(--toc-w);
  grid-template-areas: "side main toc";
  align-items: start;
  min-height: 100vh;
}

/* ==========================================================================
   2. 左侧边栏（结构总览 = 目录）
   ========================================================================== */

.sidebar {
  grid-area: side;
  background: var(--bg-side);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.side-head {
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .2px;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 30px; height: 30px; flex: none;
  border-radius: 9px;
  background: linear-gradient(150deg, #6d86ff, var(--brand));
  color: #fff;
  display: grid; place-items: center;
  font-size: 15px; font-weight: 700;
  box-shadow: var(--shadow-sm);
}

.brand-sub {
  margin: 8px 0 0 40px;
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.5;
}

.side-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px 26px;
}

.side-group { margin-bottom: 4px; }

.side-group-title {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 8px 10px 6px;
  border: 0;
  background: none;
  color: var(--text-3);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .6px;
  cursor: pointer;
}
.side-group-title:hover { color: var(--text-2); }

.side-group-title .caret {
  width: 12px;
  font-size: 10px;
  transition: transform .18s ease;
  color: #a9b0bd;
}
.side-group.collapsed .caret { transform: rotate(-90deg); }
.side-group.collapsed .side-list { display: none; }

.side-list { list-style: none; margin: 0; padding: 0; }

/* 一级项：像 DeepSeek 的会话条目 */
.side-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  margin: 1px 0;
  border-radius: 9px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.4;
  transition: background .14s ease, color .14s ease;
}
.side-link:hover { background: #eef1f7; color: var(--text); text-decoration: none; }
.side-link.active { background: #e6ebff; color: var(--brand-deep); font-weight: 600; }

.side-link .ico { font-size: 14px; width: 17px; text-align: center; flex: none; }
.side-link .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 二级项：当前章节的小节 */
.side-sub { list-style: none; margin: 2px 0 8px; padding: 0 0 0 27px; }
.side-sub a {
  display: block;
  padding: 4px 8px;
  border-radius: 7px;
  color: var(--text-3);
  font-size: 12.5px;
  line-height: 1.5;
  border-left: 2px solid transparent;
}
.side-sub a:hover { color: var(--text-2); background: #f1f4f9; text-decoration: none; }
.side-sub a.active {
  color: var(--brand-deep);
  border-left-color: var(--brand);
  background: #f0f3ff;
}

.side-foot {
  border-top: 1px solid var(--line);
  padding: 10px 14px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--text-3);
}

.side-foot .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==========================================================================
   3. 中间正文区
   ========================================================================== */

.main {
  grid-area: main;
  align-self: start;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.main-bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 12px var(--gutter);
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.crumb { font-size: 13px; color: var(--text-3); display: flex; align-items: center; gap: 7px; }
.crumb a { color: var(--text-3); }
.crumb a:hover { color: var(--brand); text-decoration: none; }
.crumb .sep { color: #c8cdd8; }
.crumb .now { color: var(--text-2); }

.bar-actions { margin-left: auto; display: flex; gap: 8px; }

.chip {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text-2);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: .15s ease;
}
.chip:hover { border-color: #c3cdec; color: var(--brand-deep); background: var(--brand-soft); }

.content { padding: 30px var(--gutter) 90px; max-width: 860px; width: 100%; }

/* ---------- 动效：进入页面时轻微上浮（像新消息出现） ---------- */
.view-enter { animation: rise .28s ease both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- 标题层级 ---------- */

.page-eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 600; letter-spacing: .8px;
  color: var(--brand-deep);
  background: var(--brand-soft);
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  margin-bottom: 14px;
}

h1 {
  font-size: 30px;
  line-height: 1.35;
  margin: 0 0 14px;
  letter-spacing: -.4px;
}

h2 {
  font-size: 20px;
  margin: 44px 0 14px;
  padding-top: 6px;
  letter-spacing: -.2px;
  scroll-margin-top: 78px;
}

h3 {
  font-size: 16.5px;
  margin: 28px 0 10px;
  color: var(--text);
  scroll-margin-top: 78px;
}

h2 + h3 { margin-top: 14px; }

p { margin: 0 0 14px; color: var(--text-2); }
strong { color: var(--text); font-weight: 650; }

ul, ol { margin: 0 0 14px; padding-left: 22px; color: var(--text-2); }
li { margin: 5px 0; }
li::marker { color: #b4bccc; }

.lead {
  font-size: 16.5px;
  color: var(--text-2);
  margin-bottom: 18px;
}

/* 章节之间的细分隔线（h2 上方） */
h2::before {
  content: "";
  display: block;
  height: 1px;
  background: var(--line);
  margin-bottom: 24px;
}
h2:first-of-type::before { display: none; }

/* ---------- 行内代码 / 代码块 ---------- */

code {
  font-family: "Cascadia Code", Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: .88em;
  background: var(--bg-code);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
  color: #b3306b;
}

pre {
  background: var(--bg-code);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.65;
  margin: 0 0 16px;
}
pre code { background: none; border: 0; padding: 0; color: #24292f; }

/* ---------- Hero（仿聊天首屏） ---------- */

.hero {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 30px 30px 26px;
  margin-bottom: 8px;
}

.hero .hi { font-size: 13px; color: var(--text-3); margin-bottom: 6px; }
.hero h1 { font-size: 32px; margin-bottom: 12px; }
.hero .lead { margin-bottom: 20px; }

.status-line {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-2);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  padding: 5px 14px 5px 11px;
}

.pulse {
  width: 7px; height: 7px; border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, .5);
  animation: pulse 2.2s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, .45); }
  70%  { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.cta-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text-2);
  cursor: pointer;
  transition: .15s ease;
}
.btn:hover { text-decoration: none; border-color: #c3cdec; color: var(--brand-deep); background: var(--brand-soft); }
.btn.primary {
  background: var(--brand); border-color: var(--brand); color: #fff;
  box-shadow: 0 4px 14px rgba(77, 107, 254, .25);
}
.btn.primary:hover { background: var(--brand-deep); border-color: var(--brand-deep); color: #fff; }

/* ---------- 卡片 / 网格 ---------- */

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); }

.card {
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  background: #fff;
  color: inherit;
  transition: .18s ease;
}
.card:hover {
  text-decoration: none;
  border-color: #c8d3f6;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.card .k { font-size: 12px; color: var(--text-3); letter-spacing: .5px; }
.card .t { font-weight: 650; margin: 5px 0 6px; font-size: 15.5px; }
.card .d { font-size: 13.5px; color: var(--text-3); line-height: 1.62; margin: 0; }
.card .foot { margin-top: 10px; font-size: 12.5px; color: var(--brand-deep); }

/* ---------- 引用 / 高亮框 ---------- */

.quote {
  border-left: 3px solid var(--brand);
  background: linear-gradient(90deg, #f4f7ff, #fbfcff);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 18px;
  margin: 0 0 16px;
  color: var(--text-2);
}
.quote p:last-child { margin-bottom: 0; }

.note {
  background: var(--amber-soft);
  border: 1px solid var(--amber-line);
  border-radius: var(--radius);
  padding: 13px 16px;
  font-size: 14px;
  color: #6b5316;
  margin: 0 0 16px;
}
.note b { color: var(--amber); }
.note ul { color: #6b5316; margin-bottom: 0; }

.placeholder {
  display: inline-block;
  background: #fff4f4;
  border: 1px dashed #e9b1b1;
  color: #b04a4a;
  border-radius: 6px;
  padding: 0 6px;
  font-size: .92em;
}

/* ---------- 表格 ---------- */

.table-wrap { overflow-x: auto; margin: 0 0 18px; }

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
th, td {
  text-align: left;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  color: var(--text-2);
}
th { background: var(--bg-soft); font-weight: 600; color: var(--text); white-space: nowrap; }
td code { white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfe; }

/* ---------- 项目元信息（聊天气泡感的定义列表） ---------- */

.meta {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 0 0 18px;
  font-size: 14px;
}
.meta .row { display: flex; gap: 0; border-bottom: 1px solid var(--line); }
.meta .row:last-child { border-bottom: 0; }
.meta .row:nth-child(odd) { background: #fcfdff; }
.meta .k {
  flex: none; width: 104px;
  padding: 9px 14px;
  color: var(--text-3);
  font-size: 13px;
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
}
.meta .v { padding: 9px 14px; color: var(--text-2); }

/* ---------- 图片 ---------- */

figure { margin: 0 0 20px; }
figure img, .shot img {
  width: 100%; height: auto; display: block;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background: var(--bg-soft);
}
figcaption {
  font-size: 12.5px;
  color: var(--text-3);
  margin-top: 8px;
  line-height: 1.6;
}
.shot-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }

/* “过程 / 结果 / 反思”三段式小标题 */
.stage {
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius);
  padding: 14px 18px 4px;
  margin: 0 0 14px;
  background: #fdfdff;
}
.stage h3 { margin-top: 0; }
.stage p:last-child { margin-bottom: 12px; }

/* ---------- 标签 ---------- */

.tags { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 18px; }
.tag {
  font-size: 12.5px;
  color: var(--text-2);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 3px 12px;
}
.tag.on { color: var(--brand-deep); background: var(--brand-soft); border-color: #d6dfff; }

/* ---------- 时间线（学习/探索路径） ---------- */

.tl { list-style: none; margin: 0 0 18px; padding: 0; }
.tl li {
  position: relative;
  padding: 0 0 16px 22px;
  border-left: 1px solid var(--line-strong);
}
.tl li:last-child { padding-bottom: 0; border-left-color: transparent; }
.tl li::before {
  content: ""; position: absolute; left: -4.5px; top: 10px;
  width: 8px; height: 8px; border-radius: 50%;
  background: #fff; border: 2px solid var(--brand);
}
.tl .when { font-size: 12.5px; color: var(--text-3); }
.tl .what { font-weight: 600; color: var(--text); }
.tl .desc { font-size: 13.5px; color: var(--text-3); }

/* ==========================================================================
   4. 右侧小目录（当前页面内的标题目录）
   ========================================================================== */

.toc {
  grid-area: toc;
  align-self: start;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  /* 顶部让开中间那条吸顶标题栏，避免目录第一项被裁掉 */
  padding: 66px 22px 40px 4px;
  font-size: 13px;
}

.toc-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .7px;
  color: var(--text-3);
  margin-bottom: 10px;
  padding-left: 11px;
}

.toc ul { list-style: none; margin: 0; padding: 0; }

.toc a {
  display: block;
  padding: 5px 10px;
  border-radius: 7px;
  color: var(--text-3);
  line-height: 1.5;
  border-left: 2px solid transparent;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.toc a:hover { color: var(--text-2); background: #f4f6fa; text-decoration: none; }
.toc a.active {
  color: var(--brand-deep);
  background: var(--brand-soft);
  border-left-color: var(--brand);
  font-weight: 600;
}
.toc .lv3 a { padding-left: 22px; font-size: 12.5px; }
.toc .empty { padding-left: 11px; color: #b6bcc7; font-size: 12.5px; }

/* 回到顶部 */
.to-top {
  position: fixed; right: calc(var(--toc-w) + 18px); bottom: 26px;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text-2);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  display: none;
  place-items: center;
  font-size: 15px;
  z-index: 30;
}
.to-top.show { display: grid; }
.to-top:hover { color: var(--brand-deep); border-color: #c3cdec; }

/* ==========================================================================
   5. 响应式
   ========================================================================== */

.menu-btn { display: none; }

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: var(--side-w) minmax(0, 1fr);
    grid-template-areas: "side main";
  }
  .toc { display: none; }
  .to-top { right: 20px; }
}

@media (max-width: 860px) {
  :root { --gutter: 20px; }

  .layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "main";
  }

  .sidebar {
    grid-area: main;
    position: fixed; z-index: 60;
    left: 0; top: 0; width: 280px;
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(20, 28, 60, .18);
  }
  .sidebar.open { transform: none; }

  .scrim {
    grid-area: main;
    position: fixed; inset: 0; z-index: 55;
    background: rgba(18, 24, 45, .35);
    display: none;
  }
  .scrim.show { display: block; }

  .menu-btn {
    display: grid; place-items: center;
    width: 34px; height: 34px; flex: none;
    border-radius: 9px;
    border: 1px solid var(--line-strong);
    background: #fff; color: var(--text-2);
    cursor: pointer; font-size: 15px;
  }

  h1 { font-size: 25px; }
  .hero { padding: 22px 20px; }
  .hero h1 { font-size: 26px; }
  .content { padding: 22px var(--gutter) 70px; }
  .meta .row { flex-direction: column; }
  .meta .k { width: auto; border-right: 0; border-bottom: 1px solid var(--line); }
}

/* 打印（可当作品集 PDF 用） */
@media print {
  .sidebar, .toc, .main-bar, .to-top { display: none !important; }
  .layout { grid-template-columns: 1fr; }
  .content { max-width: none; padding: 0; }
  .card:hover { transform: none; box-shadow: none; }
}
