/* ==========================================================================
   南梁养成手册 — 浅粉蓝主题
   ========================================================================== */

:root {
  --bg: #fdfbfd;
  --card: #ffffff;

  --ink: #3b3547;
  --ink-2: #625c72;
  --ink-3: #9a93a6;

  --pink: #e88aae;
  --pink-d: #d16f96;
  --pink-soft: #fdeaf2;
  --pink-line: #f6d6e4;

  --blue: #7fb0e6;
  --blue-d: #5b92ce;
  --blue-soft: #e9f3fd;
  --blue-line: #cfe2f7;

  --line: #efe9f2;
  --shadow-sm: 0 2px 8px rgba(150, 130, 170, .06);
  --shadow: 0 12px 34px rgba(170, 145, 175, .12), 0 2px 6px rgba(120, 140, 180, .05);
  --r: 18px;
  --topbar-h: 66px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(900px 520px at 8% -8%, #fdeef4 0%, rgba(253, 238, 244, 0) 62%),
    radial-gradient(880px 520px at 96% 2%, #e9f3fe 0%, rgba(233, 243, 254, 0) 60%),
    var(--bg);
  background-attachment: fixed;
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

/* ---------- 顶部阅读进度 ---------- */
.progress {
  position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 60;
  background: transparent; pointer-events: none;
}
.progress i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--pink), var(--blue));
  transition: width .12s linear;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 20px;
  padding: 0 clamp(16px, 4vw, 40px);
  background: rgba(255, 255, 255, .76);
  backdrop-filter: saturate(150%) blur(14px);
  -webkit-backdrop-filter: saturate(150%) blur(14px);
  border-bottom: 1px solid rgba(239, 233, 242, .9);
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(135deg, #f4a5c1, #93bdec);
  color: #fff; font-size: 14px; font-weight: 700; letter-spacing: .5px;
  box-shadow: 0 6px 14px rgba(226, 150, 180, .32);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text b { font-size: 15.5px; letter-spacing: .3px; }
.brand-text i {
  font-style: normal; font-size: 11.5px; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.search {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  width: min(300px, 34vw);
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: border-color .2s, box-shadow .2s;
}
.search:focus-within { border-color: var(--pink-line); box-shadow: 0 0 0 4px rgba(253, 234, 242, .9); }
.search svg {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: var(--ink-3); stroke-width: 1.8; stroke-linecap: round;
}
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  font-size: 13.5px; color: var(--ink);
}
.search input::placeholder { color: var(--ink-3); }

.topbar-right { display: flex; align-items: center; gap: 10px; }
.count {
  font-size: 12px; color: var(--ink-3);
  padding: 3px 10px; border-radius: 999px;
  background: var(--blue-soft); white-space: nowrap;
}
.menu-btn {
  display: none; width: 36px; height: 36px; padding: 0;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  cursor: pointer;
}
.menu-btn svg { width: 18px; height: 18px; fill: none; stroke: var(--ink-2); stroke-width: 1.8; stroke-linecap: round; }

/* ---------- 布局 ---------- */
.layout {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  gap: clamp(20px, 3vw, 44px);
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 34px clamp(16px, 4vw, 40px) 40px;
  align-items: start;
}

/* 首页没有侧栏，内容收窄到更适合阅读的宽度 */
.layout.solo {
  grid-template-columns: minmax(0, 1fr);
  width: min(880px, 100%);
}
.layout.solo .sidebar { display: none; }
body.no-side .menu-btn { display: none; }

/* ---------- 侧栏 ---------- */
.sidebar {
  position: sticky; top: calc(var(--topbar-h) + 22px);
  max-height: calc(100vh - var(--topbar-h) - 44px);
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--pink-line) transparent;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--pink-line); border-radius: 99px; }

.side-title {
  font-size: 11px; letter-spacing: 2px; color: var(--ink-3);
  margin: 0 0 12px 10px;
}
.side-item {
  display: flex; align-items: baseline; gap: 10px; position: relative;
  padding: 8px 12px; margin-bottom: 2px;
  border-radius: 10px;
  font-size: 13.5px; color: var(--ink-2);
  transition: background .16s, color .16s;
}
.side-item:hover { background: #fff; color: var(--ink); }
.side-no {
  flex: none; font-size: 11px; color: var(--ink-3);
  font-variant-numeric: tabular-nums; letter-spacing: .5px;
}
.side-name { min-width: 0; }
.side-item.on {
  background: linear-gradient(90deg, var(--pink-soft), var(--blue-soft));
  color: var(--ink); font-weight: 600;
}
.side-item.on .side-no { color: var(--pink-d); }
.side-item.on::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 16px; border-radius: 99px;
  background: linear-gradient(180deg, var(--pink), var(--blue));
}
.side-empty { font-size: 12.5px; color: var(--ink-3); margin-left: 10px; }

/* ---------- 首页 ---------- */
.hero {
  position: relative; overflow: hidden;
  padding: clamp(26px, 4vw, 44px);
  border: 1px solid #fff;
  border-radius: 26px;
  background: linear-gradient(120deg, #fff 0%, #fef7fa 46%, #f2f8ff 100%);
  box-shadow: var(--shadow);
  margin-bottom: 26px;
}
.hero::after {
  content: ""; position: absolute; right: -70px; bottom: -90px;
  width: 260px; height: 260px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(127, 176, 230, .28), rgba(232, 138, 174, .16) 60%, transparent 72%);
  filter: blur(6px);
}
.hero .tag {
  display: inline-block; font-size: 11.5px; letter-spacing: 1.6px;
  color: var(--pink-d); background: #fff;
  border: 1px solid var(--pink-line);
  padding: 3px 11px; border-radius: 999px; margin-bottom: 16px;
}
.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(24px, 3.4vw, 34px);
  line-height: 1.4; letter-spacing: .5px;
  font-weight: 700;
}
.hero h1 em {
  font-style: normal;
  background: linear-gradient(100deg, var(--pink-d), var(--blue-d));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p {
  margin: 0; max-width: 46em;
  font-size: 14px; color: var(--ink-2); line-height: 1.9;
}
.hero-stats { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; position: relative; z-index: 1; }
.hero-stats span {
  font-size: 12.5px; color: var(--ink-2);
  background: rgba(255, 255, 255, .82);
  border: 1px solid var(--line);
  padding: 6px 13px; border-radius: 999px;
}
.hero-stats b { color: var(--pink-d); font-weight: 700; }

.section-head {
  display: flex; align-items: baseline; gap: 10px;
  margin: 0 0 14px 2px;
}
.section-head h2 { margin: 0; font-size: 15px; letter-spacing: .4px; }
.section-head span { font-size: 12px; color: var(--ink-3); }

/* 目录列表 */
.list { display: flex; flex-direction: column; gap: 10px; }

.row {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 18px;
  padding: 18px 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s;
}
.row::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--pink), var(--blue));
  opacity: 0; transition: opacity .22s;
}
.row:hover {
  transform: translateX(4px);
  border-color: var(--pink-line);
  box-shadow: var(--shadow);
}
.row:hover::before { opacity: 1; }

.row .no {
  flex: none;
  font-size: 12px; font-weight: 600; letter-spacing: .5px;
  color: var(--pink-d);
  background: var(--pink-soft);
  width: 34px; height: 34px; border-radius: 11px;
  display: grid; place-items: center;
  font-variant-numeric: tabular-nums;
}
.row .body { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.row .body b {
  font-size: 16px; font-weight: 600; letter-spacing: .2px;
  line-height: 1.5; color: var(--ink);
}
.row .body i {
  font-style: normal; font-size: 12.5px; color: var(--ink-3); line-height: 1.7;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row .tail {
  margin-left: auto; flex: none;
  display: flex; align-items: center; gap: 14px;
  font-size: 11.5px; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.row .arrow {
  color: var(--pink-d); font-size: 15px;
  opacity: 0; transform: translateX(-4px);
  transition: opacity .22s, transform .22s;
}
.row:hover .arrow { opacity: 1; transform: none; }

/* ---------- 文章 ---------- */
.crumb {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--ink-3); margin-bottom: 16px;
}
.crumb a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px;
  background: rgba(255, 255, 255, .7); border: 1px solid var(--line);
  transition: color .2s, border-color .2s;
}
.crumb a:hover { color: var(--pink-d); border-color: var(--pink-line); }

.article {
  padding: clamp(24px, 4vw, 46px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.article > header { padding-bottom: 20px; margin-bottom: 6px; border-bottom: 1px dashed var(--pink-line); }
.article h1 {
  margin: 0 0 12px;
  font-size: clamp(23px, 3vw, 30px); line-height: 1.45; letter-spacing: .3px;
}
.article .meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  font-size: 12px; color: var(--ink-3);
}
.article .meta .sep { opacity: .5; }

.toc {
  margin: 22px 0 4px; padding: 14px 18px;
  background: linear-gradient(120deg, #fef8fb, #f4f9ff);
  border: 1px solid var(--line); border-radius: 14px;
  font-size: 13px;
}
.toc summary {
  cursor: pointer; color: var(--ink-2); font-weight: 600;
  list-style: none; display: flex; align-items: center; gap: 8px;
}
.toc summary::-webkit-details-marker { display: none; }
.toc summary::before {
  content: ""; width: 6px; height: 6px; border-radius: 2px;
  background: linear-gradient(135deg, var(--pink), var(--blue));
}
.toc ol { margin: 10px 0 2px; padding-left: 20px; color: var(--ink-2); }
.toc li { margin: 4px 0; line-height: 1.7; }
.toc a:hover { color: var(--pink-d); }

/* 正文排版 */
.prose { font-size: 15.5px; line-height: 1.95; color: #454050; padding-top: 8px; }
.prose > *:first-child { margin-top: 18px; }
.prose h2 {
  position: relative;
  margin: 44px 0 14px; padding-left: 14px;
  font-size: 20px; line-height: 1.55; color: var(--ink); letter-spacing: .3px;
  scroll-margin-top: calc(var(--topbar-h) + 24px);
}
.prose h2::before {
  content: ""; position: absolute; left: 0; top: .32em; bottom: .32em; width: 4px;
  border-radius: 99px;
  background: linear-gradient(180deg, var(--pink), var(--blue));
}
.prose h3 {
  margin: 30px 0 10px; font-size: 16.5px; color: var(--ink);
  scroll-margin-top: calc(var(--topbar-h) + 24px);
}
.prose h3::before { content: "# "; color: var(--pink-line); font-weight: 400; }
.prose p { margin: 13px 0; }
.prose strong {
  font-weight: 700; color: #3b3547;
  background: linear-gradient(transparent 58%, #fbd7e6 58%, #fbd7e6 92%, transparent 92%);
  padding: 0 1px;
}
.prose em { color: var(--blue-d); font-style: normal; }
.prose a { color: var(--blue-d); border-bottom: 1px solid var(--blue-line); }
.prose a:hover { color: var(--pink-d); border-color: var(--pink-line); }
.prose ul, .prose ol { margin: 13px 0; padding-left: 1.4em; }
.prose li { margin: 6px 0; }
.prose ul > li::marker { color: var(--pink); }
.prose ol > li::marker { color: var(--blue-d); font-size: .9em; }
.prose li > ul, .prose li > ol { margin: 6px 0; }

.prose blockquote {
  margin: 20px 0; padding: 12px 18px;
  background: var(--blue-soft);
  border-left: 3px solid var(--blue);
  border-radius: 4px 12px 12px 4px;
  color: #4a5468; font-size: 14px;
}
.prose blockquote p { margin: 4px 0; }

.prose table {
  width: 100%; margin: 20px 0;
  border-collapse: separate; border-spacing: 0;
  font-size: 13.5px; line-height: 1.7;
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
}
.prose thead th {
  background: linear-gradient(120deg, #fdf1f6, #eff6ff);
  color: var(--ink); font-weight: 600; text-align: left;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.prose tbody td { padding: 10px 14px; border-bottom: 1px solid #f6f2f8; color: var(--ink-2); }
.prose tbody tr:last-child td { border-bottom: 0; }
.prose tbody tr:nth-child(even) { background: #fdfbfd; }

.prose code {
  font-family: "SFMono-Regular", ui-monospace, Consolas, monospace;
  font-size: .88em;
  background: #f9f2f7; color: #b4618b;
  padding: .15em .42em; border-radius: 5px;
  border: 1px solid #f4e6ef;
}
.prose pre {
  margin: 18px 0; padding: 16px 18px; overflow-x: auto;
  background: #fbf8fc; border: 1px solid var(--line); border-radius: 14px;
}
.prose pre code { background: none; border: 0; padding: 0; color: #4b4558; font-size: 13px; }

.prose hr {
  margin: 34px 0; border: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--pink-line), var(--blue-line), transparent);
}
.prose img { max-width: 100%; border-radius: 12px; box-shadow: var(--shadow-sm); }

/* 上下篇 */
.pager { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; margin-top: 26px; }
.pager a {
  padding: 14px 18px; border: 1px solid var(--line); border-radius: 14px;
  background: #fff; box-shadow: var(--shadow-sm);
  font-size: 13px; color: var(--ink-2);
  transition: border-color .2s, transform .2s;
}
.pager a:hover { border-color: var(--pink-line); transform: translateY(-2px); }
.pager a span { display: block; font-size: 11px; color: var(--ink-3); margin-bottom: 4px; }
.pager a.next { text-align: right; }

/* ---------- 状态 ---------- */
.state {
  padding: 46px 24px; text-align: center;
  border: 1px dashed var(--pink-line); border-radius: 20px;
  background: rgba(255, 255, 255, .6);
  color: var(--ink-2); font-size: 14px;
}
.state b { display: block; color: var(--ink); margin-bottom: 8px; font-size: 15.5px; }
.state code { background: #f9f2f7; color: #b4618b; padding: 1px 6px; border-radius: 5px; font-size: 12.5px; }

.skel { height: 15px; border-radius: 8px; margin: 12px 0; background: linear-gradient(90deg, #f8f3f8, #eef4fc, #f8f3f8); background-size: 200% 100%; animation: sheen 1.4s infinite; }
.skel.w60 { width: 60%; } .skel.w85 { width: 85%; } .skel.h28 { height: 26px; margin-top: 26px; }
@keyframes sheen { 0% { background-position: 0% 0; } 100% { background-position: -200% 0; } }

/* ---------- 页脚 / 回顶 ---------- */
.foot { width: min(1180px, 100%); margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px) 48px; }
.foot-line { height: 1px; background: linear-gradient(90deg, transparent, var(--pink-line), var(--blue-line), transparent); }
.foot p { margin: 16px 0 0; text-align: center; font-size: 11.5px; color: var(--ink-3); letter-spacing: .4px; }

.to-top {
  position: fixed; right: 22px; bottom: 24px; z-index: 40;
  width: 42px; height: 42px; padding: 0;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 50%;
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow);
  cursor: pointer; opacity: 0; transform: translateY(8px);
  transition: opacity .25s, transform .25s;
  pointer-events: none;
}
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top svg { width: 18px; height: 18px; fill: none; stroke: var(--pink-d); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  :root { --topbar-h: 60px; }
  .brand-text i { display: none; }
  .menu-btn { display: grid; place-items: center; }
  .search { width: auto; flex: 1; min-width: 0; }
  .count { display: none; }

  .layout { grid-template-columns: 1fr; padding-top: 20px; gap: 18px; }

  .sidebar {
    position: fixed; top: var(--topbar-h); left: 0; right: 0; z-index: 45;
    max-height: 0; overflow: hidden;
    padding: 0 clamp(16px, 4vw, 40px);
    background: #fff;
    border-bottom: 1px solid transparent;
    transition: max-height .3s ease, padding .3s ease;
  }
  body.nav-open .sidebar {
    max-height: 62vh; overflow-y: auto;
    padding: 16px clamp(16px, 4vw, 40px) 20px;
    border-bottom-color: var(--line);
    box-shadow: 0 18px 30px rgba(150, 130, 170, .12);
  }
  .article { padding: 22px 20px; border-radius: 20px; }
  .prose { font-size: 15px; }
  .pager { grid-template-columns: 1fr; }
  .pager a.next { text-align: left; }
}

@media (max-width: 560px) {
  .search input::placeholder { font-size: 12.5px; }
  .hero-stats span { font-size: 11.5px; padding: 5px 10px; }
  .row { gap: 12px; padding: 15px 16px; align-items: flex-start; }
  .row .no { width: 28px; height: 28px; border-radius: 9px; font-size: 11px; }
  .row .body b { font-size: 15px; }
  .row .body i { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .row .tail { flex-direction: column; align-items: flex-end; gap: 2px; }
  .row .arrow { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

@media print {
  .topbar, .sidebar, .to-top, .progress, .foot, .pager { display: none !important; }
  .layout { display: block; padding: 0; width: 100%; }
  .article { border: 0; box-shadow: none; padding: 0; }
}
