:root {
  color-scheme: light;
  --brand: #e5484d;
  --brand-dark: #be353a;
  --brand-soft: #fff1f1;
  --ink: #1d252d;
  --muted: #67717d;
  --line: #e7e9ec;
  --canvas: #f6f7f8;
  --panel: #ffffff;
  --shadow: 0 10px 34px rgba(28, 35, 43, 0.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font: 15px/1.72 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; }

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 230px;
  max-width: 1600px;
  margin: 0 auto;
}

.sidebar,
.toc {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  background: var(--panel);
}

.sidebar {
  padding: 28px 22px;
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: white;
  background: linear-gradient(145deg, #f15d62, var(--brand-dark));
  font-size: 22px;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(229, 72, 77, 0.25);
}
.brand strong,
.brand small,
.status-card strong,
.status-card small { display: block; }
.brand small,
.status-card small { color: var(--muted); margin-top: 2px; font-size: 12px; }

.status-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  border: 1px solid #f3cccc;
  border-radius: 14px;
  background: var(--brand-soft);
}
.status-dot {
  width: 9px;
  height: 9px;
  margin-top: 6px;
  border-radius: 50%;
  background: #27a468;
  box-shadow: 0 0 0 4px rgba(39, 164, 104, 0.12);
}

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 20px 0; }
.stats div { padding: 12px; border-radius: 12px; background: #f7f8f9; text-align: center; }
.stats dt { font-size: 21px; font-weight: 800; line-height: 1.2; }
.stats dd { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.side-actions { display: grid; gap: 8px; }
.side-actions a { padding: 10px 12px; border-radius: 10px; color: var(--ink); background: #f7f8f9; }
.side-actions a:hover { color: var(--brand-dark); background: var(--brand-soft); text-decoration: none; }
.sidebar-note { margin: 22px 2px 0; color: var(--muted); font-size: 12px; }

.main { min-width: 0; padding: 0 38px 40px; }
.topbar {
  position: sticky;
  z-index: 5;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 12px 0;
  background: rgba(246, 247, 248, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.topbar strong { display: block; font-size: 16px; }
.topbar > a { padding: 9px 13px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.eyebrow { display: block; color: var(--brand-dark); font-size: 10px; font-weight: 800; letter-spacing: 0.12em; }

.markdown-body {
  max-width: 980px;
  margin: 26px auto 0;
  padding: 48px 54px 64px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.markdown-body h1 { margin: 0 0 8px; font-size: clamp(30px, 4vw, 44px); line-height: 1.15; letter-spacing: -0.035em; }
.markdown-body h2 { margin: 54px 0 20px; padding-top: 8px; font-size: 26px; line-height: 1.3; border-top: 1px solid var(--line); }
.markdown-body h3 { margin: 38px 0 16px; font-size: 20px; }
.markdown-body h4 { margin: 28px 0 12px; font-size: 17px; }
.markdown-body h1 + blockquote { margin-top: 12px; }
.heading-link { margin-left: 8px; opacity: 0; font-weight: 500; }
h2:hover .heading-link,
h3:hover .heading-link,
h4:hover .heading-link { opacity: 0.55; }
.markdown-body p { margin: 12px 0; }
.markdown-body ul,
.markdown-body ol { padding-left: 24px; }
.markdown-body li + li { margin-top: 5px; }
.markdown-body blockquote {
  margin: 18px 0;
  padding: 12px 18px;
  color: var(--muted);
  border-left: 4px solid var(--brand);
  border-radius: 0 10px 10px 0;
  background: var(--brand-soft);
}
.markdown-body code {
  padding: 2px 6px;
  border-radius: 6px;
  color: #9c2f33;
  background: #fff0f0;
  font: 0.9em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.markdown-body pre { overflow: auto; padding: 18px; border-radius: 12px; color: #edf0f3; background: #20262d; }
.markdown-body pre code { padding: 0; color: inherit; background: transparent; }
.table-wrap {
  width: 100%;
  margin: 18px 0 28px;
  overflow-x: auto;
  border-radius: 12px;
}
.markdown-body table {
  width: 100%;
  min-width: 680px;
  margin: 0;
  border-spacing: 0;
  border-collapse: separate;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.markdown-body thead { background: #f5f6f7; }
.markdown-body th,
.markdown-body td { min-width: 120px; padding: 11px 13px; text-align: left; vertical-align: top; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.markdown-body th:last-child,
.markdown-body td:last-child { border-right: 0; }
.markdown-body tbody tr:last-child td { border-bottom: 0; }
.markdown-body th { font-size: 13px; white-space: nowrap; }
.markdown-body strong { font-weight: 750; }

.toc { padding: 30px 18px; border-left: 1px solid var(--line); }
.toc-title { margin: 0 8px 12px; font-size: 12px; font-weight: 800; color: var(--muted); letter-spacing: 0.08em; }
.toc nav { display: grid; gap: 2px; }
.toc-link { padding: 7px 9px; border-radius: 8px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.toc-link.level-3 { padding-left: 20px; }
.toc-link:hover,
.toc-link.active { color: var(--brand-dark); background: var(--brand-soft); text-decoration: none; }

footer { max-width: 980px; margin: 24px auto 0; color: var(--muted); text-align: center; font-size: 12px; }
.mobile-header { display: none; }
.back-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 13px;
  color: white;
  background: var(--brand);
  box-shadow: 0 8px 22px rgba(229, 72, 77, 0.28);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.back-top.show { opacity: 1; pointer-events: auto; }

@media (max-width: 1180px) {
  .layout { grid-template-columns: 238px minmax(0, 1fr); }
  .toc { display: none; position: fixed; z-index: 20; right: 0; top: 58px; width: min(310px, 86vw); height: calc(100vh - 58px); box-shadow: -12px 0 36px rgba(0,0,0,0.12); }
  .toc.open { display: block; }
  .topbar { top: 0; }
}

@media (max-width: 760px) {
  body { padding-top: 58px; }
  .mobile-header {
    position: fixed;
    z-index: 30;
    top: 0;
    left: 0;
    right: 0;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    border-bottom: 1px solid var(--line);
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(12px);
  }
  .mobile-header button { border: 0; padding: 8px; color: var(--brand-dark); background: transparent; }
  .layout { display: block; }
  .sidebar { display: none; position: fixed; z-index: 20; top: 58px; left: 0; width: min(310px, 88vw); height: calc(100vh - 58px); box-shadow: 12px 0 36px rgba(0,0,0,0.12); }
  .sidebar.open { display: block; }
  .main { padding: 0 12px 28px; }
  .topbar { display: none; }
  .markdown-body { margin-top: 12px; padding: 28px 20px 42px; border-radius: 14px; }
  .markdown-body h2 { margin-top: 42px; font-size: 23px; }
  .markdown-body th,
  .markdown-body td { min-width: 140px; padding: 10px; }
  .back-top { right: 14px; bottom: 14px; }
}

@media print {
  .sidebar, .toc, .topbar, .mobile-header, .back-top { display: none !important; }
  .layout { display: block; }
  .main { padding: 0; }
  .markdown-body { max-width: none; margin: 0; padding: 0; border: 0; box-shadow: none; }
}
