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

:root {
  --ink: #3f2a10;
  --ink-soft: #6f4d1a;
  --line: rgba(95, 62, 19, 0.28);
  --peak: #ffd786;
  --card-bg: linear-gradient(180deg, rgba(246, 226, 163, 0.92), rgba(228, 198, 117, 0.88));
  --card-shadow: 0 12px 24px rgba(47, 28, 9, 0.36);
  --panel-bg: linear-gradient(180deg, rgba(241, 218, 154, 0.93), rgba(217, 179, 89, 0.9));
  --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", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  color: var(--ink);
  font-family: var(--font-body);
  overflow: hidden;
  background:
    radial-gradient(1100px 600px at 50% -260px, rgba(233, 194, 94, 0.23), transparent 70%),
    linear-gradient(180deg, #4a3111 0%, #8b6025 24%, #cca95a 55%, #cfaf62 100%);
}

a {
  color: #4c2e0f;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

#scene-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: auto;
}

.timeline-splash {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background:
    radial-gradient(960px 460px at 50% 45%, rgba(255, 227, 142, 0.25), transparent 70%),
    linear-gradient(95deg, rgba(53, 34, 11, 0.94), rgba(141, 99, 35, 0.91) 45%, rgba(222, 177, 74, 0.9));
  transition: opacity 700ms ease, visibility 700ms ease;
}

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

.splash-core {
  border: 1px solid rgba(112, 78, 25, 0.44);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(246, 221, 146, 0.9), rgba(192, 142, 47, 0.88));
  box-shadow: 0 26px 60px rgba(21, 13, 4, 0.58);
  padding: 36px 54px;
  text-align: center;
}

.splash-core h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(40px, 6vw, 78px);
  letter-spacing: 0.08em;
  color: #5f3c11;
}

.splash-core p {
  margin: 14px 0 0;
  font-size: clamp(18px, 2.4vw, 30px);
  color: #6a4516;
}

.topbar {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(226, 194, 108, 0.84), rgba(214, 173, 79, 0.7));
  backdrop-filter: blur(7px);
}

.title-wrap h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(24px, 3.6vw, 38px);
}

.title-wrap p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--ink-soft);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.top-actions a,
.top-actions button {
  appearance: none;
  border: 1px solid rgba(113, 76, 22, 0.22);
  border-radius: 10px;
  background: rgba(245, 226, 167, 0.58);
  color: #4c2e0f;
  padding: 7px 11px;
  font-size: 13px;
  cursor: pointer;
  line-height: 1;
}

.top-actions button:hover,
.top-actions a:hover {
  background: rgba(251, 238, 192, 0.84);
  text-decoration: none;
}

.card {
  border: 1px solid rgba(96, 63, 19, 0.25);
  border-radius: 12px;
  background: var(--card-bg);
  box-shadow: var(--card-shadow);
}

.scene-overlay {
  position: fixed;
  inset: 82px 16px 14px;
  z-index: 22;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.hud-card {
  width: min(920px, calc(100vw - 44px));
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  pointer-events: auto;
}

.hud-card h2 {
  margin: 0;
  font-size: clamp(26px, 3vw, 40px);
  font-family: var(--font-display);
}

.hud-card p {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--ink-soft);
}

.meta-block {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.meta-block span {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(98, 64, 18, 0.25);
  background: rgba(245, 229, 174, 0.78);
  font-size: 12px;
}

.overview {
  width: min(980px, calc(100vw - 44px));
  margin: 0 auto;
  padding: 10px 12px;
  pointer-events: auto;
}

.overview h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.overview-track {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(26px, 1fr));
  gap: 3px;
}

.overview-dot {
  height: 9px;
  border-radius: 999px;
  border: 0;
  background: rgba(112, 75, 21, 0.26);
  cursor: pointer;
}

.overview-dot.year {
  background: rgba(122, 83, 26, 0.4);
}

.overview-dot.theme {
  background: rgba(102, 67, 22, 0.5);
}

.overview-dot.meta {
  background: rgba(178, 132, 52, 0.75);
}

.overview-dot.peak {
  background: rgba(247, 198, 92, 0.98);
}

.overview-dot.active {
  outline: 2px solid rgba(82, 52, 14, 0.68);
}

.drawer {
  position: fixed;
  top: 82px;
  bottom: 14px;
  z-index: 32;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  border: 1px solid rgba(95, 61, 19, 0.34);
  box-shadow: 0 18px 30px rgba(35, 20, 6, 0.4);
  transition: transform 320ms ease, opacity 320ms ease;
}

.left-drawer {
  left: 14px;
  width: min(320px, calc(100vw - 28px));
  transform: translateX(calc(-100% - 20px));
  opacity: 0;
}

.right-drawer {
  right: 14px;
  width: min(430px, calc(100vw - 28px));
  transform: translateX(calc(100% + 20px));
  opacity: 0;
}

body.show-left-panel .left-drawer {
  transform: translateX(0);
  opacity: 1;
}

body.show-right-panel .right-drawer {
  transform: translateX(0);
  opacity: 1;
}

.drawer-head {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(105, 71, 21, 0.18);
  padding: 12px;
}

.drawer-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 30px;
}

.drawer-close {
  border: 1px solid rgba(109, 72, 20, 0.3);
  border-radius: 9px;
  background: rgba(245, 229, 174, 0.78);
  color: var(--ink);
  font-size: 12px;
  padding: 6px 9px;
  cursor: pointer;
}

.phase-panel {
  flex: 1 1 auto;
  overflow: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.phase-panel h2,
.phase-panel h3 {
  margin: 0;
}

.phase-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow: auto;
  padding-right: 4px;
}

.phase-btn {
  border: 1px solid rgba(109, 72, 20, 0.22);
  background: rgba(244, 226, 164, 0.75);
  color: var(--ink);
  border-radius: 8px;
  padding: 8px;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
}

.phase-btn.active {
  background: linear-gradient(90deg, rgba(113, 77, 21, 0.26), rgba(113, 77, 21, 0.09));
  border-color: rgba(113, 77, 21, 0.42);
}

.filters {
  border-top: 1px solid rgba(96, 63, 19, 0.2);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}

.filters input,
.filters select {
  border: 1px solid rgba(99, 67, 22, 0.3);
  border-radius: 8px;
  background: rgba(250, 239, 201, 0.88);
  padding: 6px 8px;
  color: #41290f;
}

.check-row {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  margin-top: 2px;
}

.legend {
  border-top: 1px solid rgba(96, 63, 19, 0.2);
  padding-top: 10px;
  font-size: 12px;
}

.legend p {
  margin: 6px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.dot.normal {
  background: #8c6326;
}

.dot.peak {
  background: var(--peak);
  box-shadow: 0 0 10px rgba(255, 210, 113, 0.9);
}

.detail-panel {
  flex: 1 1 auto;
  overflow: auto;
  padding: 12px;
  user-select: text;
}

.detail-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding-bottom: 10px;
  background: linear-gradient(180deg, rgba(244, 226, 168, 0.96), rgba(238, 214, 144, 0.91));
  border-bottom: 1px solid rgba(108, 73, 21, 0.2);
}

.detail-head h2 {
  margin: 0;
  font-size: 32px;
  font-family: var(--font-display);
}

.detail-head p {
  margin: 5px 0 8px;
  color: var(--ink-soft);
  font-size: 13px;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.detail-tags span {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(113, 77, 21, 0.12);
  border: 1px solid rgba(113, 77, 21, 0.25);
}

.detail-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(105, 71, 21, 0.18);
}

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

.rich-block {
  font-size: 15px;
  line-height: 1.72;
}

.rich-block h1,
.rich-block h2,
.rich-block h3 {
  margin: 0.7em 0 0.3em;
  color: #452b0d;
}

.rich-block blockquote {
  margin: 0.6em 0;
  padding: 0.45em 0.75em;
  border-left: 4px solid rgba(104, 67, 20, 0.35);
  background: rgba(255, 247, 225, 0.55);
}

.rich-block ol,
.rich-block ul {
  padding-left: 1.3em;
}

.fn-ref {
  color: #8b2d16;
  font-size: 0.85em;
}

.relation-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.relation-grid .item {
  font-size: 12px;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid rgba(102, 67, 19, 0.25);
  background: rgba(247, 233, 182, 0.82);
}

.doc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.doc-card {
  border: 1px solid rgba(96, 63, 19, 0.24);
  border-radius: 9px;
  background: rgba(253, 245, 214, 0.84);
  padding: 8px;
  font-size: 13px;
  line-height: 1.5;
}

.doc-card .tag {
  display: inline-block;
  margin-bottom: 5px;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(110, 73, 20, 0.12);
}

.doc-card .warn {
  color: #8b3a22;
}

@media (max-width: 1080px) {
  .hud-card,
  .overview {
    width: calc(100vw - 32px);
  }

  .drawer {
    top: 120px;
    bottom: 10px;
  }
}

@media (max-width: 780px) {
  .topbar {
    position: fixed;
    padding: 10px 12px;
    flex-direction: column;
    align-items: flex-start;
  }

  .scene-overlay {
    inset: 128px 10px 10px;
  }

  .left-drawer,
  .right-drawer {
    top: 128px;
    left: 10px;
    right: 10px;
    width: auto;
  }

  .left-drawer {
    transform: translateY(120%);
  }

  .right-drawer {
    transform: translateY(120%);
  }

  body.show-left-panel .left-drawer,
  body.show-right-panel .right-drawer {
    transform: translateY(0);
  }

  .hud-card {
    padding: 10px;
    flex-direction: column;
    align-items: flex-start;
  }

  .hud-card h2 {
    font-size: 28px;
  }

  .overview {
    padding: 8px;
  }
}
