@font-face {
  font-family: "YiGuangSong";
  src: url("../edusong_Unicode.ttf") format("truetype");
  font-display: swap;
}

:root {
  --ink: #3d2a10;
  --ink-soft: #6a4a18;
  --gold-0: #3f2b10;
  --gold-1: #7d5a1f;
  --gold-2: #c79634;
  --gold-3: #dfb64b;
  --gold-4: #ead37c;
  --paper: #f2e2a9;
  --paper-soft: #ecd89a;
  --line: rgba(89, 54, 12, 0.26);
  --font-body: "Songti SC", "STSong", "Noto Serif CJK SC", "Noto Serif SC", "Source Han Serif SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "SimSun", serif;
  --font-display: "YiGuangSong", "Songti SC", "STSong", "Noto Serif CJK SC", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(1300px 480px at 50% -220px, rgba(242, 205, 96, 0.42), transparent 72%),
    linear-gradient(90deg, var(--gold-0) 0%, var(--gold-1) 16%, var(--gold-2) 46%, var(--gold-3) 72%, #b6832b 100%);
  overflow: hidden;
}

.splash {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background:
    linear-gradient(95deg, rgba(54, 36, 11, 0.92), rgba(140, 98, 32, 0.88) 45%, rgba(215, 170, 65, 0.9));
  transition: opacity 920ms ease, visibility 920ms ease;
}

.splash::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255, 246, 198, 0.04) 0,
      rgba(255, 246, 198, 0.04) 2px,
      rgba(0, 0, 0, 0.03) 2px,
      rgba(0, 0, 0, 0.03) 4px
    );
}

.splash-core {
  position: relative;
  text-align: center;
  padding: 36px 46px;
  border-radius: 14px;
  border: 1px solid rgba(96, 64, 19, 0.42);
  background: linear-gradient(180deg, rgba(248, 226, 147, 0.88), rgba(198, 147, 48, 0.86));
  box-shadow: 0 24px 50px rgba(31, 17, 6, 0.5);
  animation: titlePulse 2.2s ease forwards;
}

.splash h1 {
  margin: 0;
  letter-spacing: 0.14em;
  font-size: clamp(34px, 6vw, 76px);
  color: #5f3e10;
  font-family: var(--font-display);
}

.splash p {
  margin: 18px 0 0;
  font-size: clamp(16px, 2.3vw, 24px);
  color: #6f4e1a;
  font-family: var(--font-body);
}

.splash.hidden {
  opacity: 0;
  visibility: hidden;
}

.app {
  height: 100vh;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 560ms ease, transform 560ms ease;
  overflow: hidden;
}

.app.ready {
  opacity: 1;
  transform: translateY(0);
}

.sidebar {
  height: 100%;
  position: sticky;
  top: 0;
  align-self: start;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background:
    linear-gradient(180deg, rgba(239, 212, 125, 0.96), rgba(214, 167, 66, 0.94));
  border-right: 1px solid var(--line);
  backdrop-filter: blur(2px);
  overflow: hidden;
}

.sidebar-head h2 {
  margin: 0;
  font-size: 22px;
  color: #583a11;
  font-family: var(--font-display);
}

.sidebar-head p {
  margin: 6px 0 14px;
  color: var(--ink-soft);
  font-size: 13px;
}

.panel {
  margin: 0;
  padding: 12px;
  border: 1px solid rgba(86, 55, 14, 0.22);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(248, 228, 157, 0.84), rgba(233, 205, 126, 0.82));
}

.panel h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.doc-list,
.toc {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.doc-list {
  max-height: 30vh;
  overflow: auto;
}

.toc-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.doc-link,
.toc-link {
  display: block;
  width: 100%;
  border: 0;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
  background: transparent;
  font-size: 14px;
  line-height: 1.45;
  padding: 6px 8px;
  border-radius: 8px;
  text-decoration: none;
  font-family: var(--font-body);
}

.doc-link:hover,
.toc-link:hover {
  background: rgba(109, 72, 20, 0.12);
}

.doc-link.active {
  background: linear-gradient(90deg, rgba(113, 77, 21, 0.22), rgba(113, 77, 21, 0.08));
  font-weight: 700;
}

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

.toc-node {
  margin: 1px 0;
}

.toc-row {
  display: grid;
  grid-template-columns: 14px 1fr;
  align-items: start;
  gap: 4px;
}

.toc-toggle {
  border: 0;
  background: transparent;
  color: #6a4a18;
  cursor: pointer;
  font-size: 11px;
  padding: 4px 0 0;
  line-height: 1;
}

.toc-spacer {
  display: inline-block;
  width: 14px;
}

.toc-children {
  margin-left: 14px;
  border-left: 1px dashed rgba(109, 72, 20, 0.24);
  padding-left: 6px;
}

.toc-children.is-collapsed {
  display: none;
}

.toc-link[data-level="1"] {
  font-size: 13px;
}

.toc-link[data-level="2"] {
  font-size: 12px;
}

.toc-link[data-level="3"] {
  font-size: 12px;
  opacity: 0.92;
}

.toc-empty {
  margin: 6px 0;
  font-size: 12px;
  color: rgba(61, 42, 16, 0.72);
}

.content-area {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  overflow: hidden;
}

.content-head {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 18px 28px 10px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(240, 217, 143, 0.66), rgba(233, 204, 121, 0.5));
}

.content-head h2 {
  margin: 0;
  font-size: 24px;
  color: #53350f;
  font-family: var(--font-display);
}

.content {
  overflow: auto;
  padding: 26px 34px 40px;
  background:
    linear-gradient(180deg, rgba(249, 236, 191, 0.82), rgba(237, 219, 161, 0.84));
  color: #31210c;
  line-height: 1.85;
  font-family: var(--font-body);
}

.content h1,
.content h2,
.content h3 {
  color: #4a300c;
  margin-top: 1.3em;
  margin-bottom: 0.48em;
  font-family: var(--font-body);
}

.content h1 {
  font-size: 30px;
  border-bottom: 1px solid rgba(101, 66, 19, 0.18);
  padding-bottom: 0.25em;
}

.content h2 {
  font-size: 24px;
}

.content h3 {
  font-size: 20px;
}

.content p,
.content li,
.content td,
.content blockquote {
  font-size: 18px;
}

.content a {
  color: #5f3b0f;
}

.content blockquote {
  margin: 0.7em 0;
  padding: 0.5em 0.9em;
  border-left: 4px solid rgba(86, 53, 13, 0.3);
  background: rgba(255, 248, 220, 0.44);
}

.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.8em 0;
}

.content th,
.content td {
  border: 1px solid rgba(84, 53, 13, 0.26);
  padding: 6px 8px;
  vertical-align: top;
}

@keyframes titlePulse {
  0% {
    opacity: 0;
    transform: translateY(22px) scale(0.98);
  }
  26% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  80% {
    opacity: 1;
    transform: scale(1.02);
  }
  100% {
    opacity: 0.96;
    transform: scale(1);
  }
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 280px minmax(0, 1fr);
    grid-template-rows: 1fr;
  }

  .sidebar {
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  .toc-wrap {
    flex: 1;
  }

  .content {
    padding: 18px 16px 24px;
  }

  .content p,
  .content li,
  .content td,
  .content blockquote {
    font-size: 16px;
  }
}

@media (max-width: 760px) {
  .app {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .content {
    padding: 16px 12px 20px;
  }
}
