* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  background: #f6e4cc;
  color: #5a3a1c;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

body[data-page="home"],
body[data-page="done"] {
  overflow: hidden;
  height: 100%;
}

body[data-page="lesson"] {
  overflow-x: hidden;
  overflow-y: auto;
  background: #388eff;
}

body[data-page="library"],
body[data-page="article"] {
  overflow-x: hidden;
  overflow-y: auto;
  background: #f4eadc;
}

img {
  max-width: 100%;
  border: 0;
  vertical-align: top;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.page-fixed.active {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.poster {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 750px;
  height: 1468px;
  transform-origin: center center;
  overflow: hidden;
}

.poster-img {
  display: block;
  width: 750px;
  height: 1468px;
  object-fit: cover;
  object-position: center top;
  pointer-events: none;
  user-select: none;
}

.enter-btn {
  position: absolute;
  left: 255px;
  top: 760px;
  width: 240px;
  height: 240px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.enter-core {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  width: 148px;
  height: 148px;
  margin: -74px 0 0 -74px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 38%, #fffaf3 0%, #f6d7b0 68%, #e8b56a 100%);
  box-shadow:
    0 10px 28px rgba(176, 108, 36, 0.28),
    inset 0 3px 10px rgba(255, 255, 255, 0.85);
  animation: breathe 2.4s ease-in-out infinite;
}

.enter-text {
  display: block;
  color: #8a4b1e;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.18em;
  line-height: 1.28;
  text-align: center;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}

.wave {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 148px;
  height: 148px;
  margin: -74px 0 0 -74px;
  border: 3px solid rgba(226, 150, 70, 0.72);
  border-radius: 50%;
  animation: ripple 2.4s ease-out infinite;
  pointer-events: none;
}

.wave:nth-child(2) {
  animation-delay: 0.8s;
}

.wave:nth-child(3) {
  animation-delay: 1.6s;
}

.enter-btn:active .enter-core {
  transform: scale(0.96);
}

@keyframes ripple {
  0% {
    transform: scale(1);
    opacity: 0.65;
  }
  100% {
    transform: scale(2.15);
    opacity: 0;
  }
}

@keyframes breathe {
  0%,
  100% {
    box-shadow:
      0 10px 28px rgba(176, 108, 36, 0.28),
      inset 0 3px 10px rgba(255, 255, 255, 0.85);
  }
  50% {
    box-shadow:
      0 12px 36px rgba(232, 165, 90, 0.45),
      inset 0 3px 10px rgba(255, 255, 255, 0.95);
  }
}

.lesson-img {
  display: block;
  width: 100%;
  height: auto;
}

.lesson-footer {
  background: #388eff;
  padding: 8px 48px calc(36px + env(safe-area-inset-bottom));
  margin-top: -1px;
}

.done-btn {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 999px;
  padding: 14px 0 16px;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.18em;
  font-family: inherit;
  background: linear-gradient(180deg, #ffd76a 0%, #ffb03a 52%, #f08c16 100%);
  box-shadow: 0 7px 0 #e07810, 0 12px 18px rgba(12, 72, 160, 0.22);
  text-shadow: 0 1px 0 rgba(176, 84, 0, 0.28);
}

.done-btn:active {
  transform: translateY(3px);
  box-shadow: 0 4px 0 #e07810, 0 8px 12px rgba(12, 72, 160, 0.18);
}

.library-btn {
  position: absolute;
  left: 178px;
  top: 952px;
  width: 394px;
  height: 64px;
  border: 0;
  padding: 0 18px 0 48px;
  background: transparent;
  color: #4a2c12;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-family: inherit;
  text-align: center;
  cursor: pointer;
}

.library-btn:active {
  opacity: 0.72;
}

.share-tip {
  position: absolute;
  left: 50%;
  top: 1098px;
  transform: translateX(-50%);
  margin: 0;
  padding: 14px 34px;
  border-radius: 999px;
  background: rgba(236, 206, 150, 0.78);
  color: #7a4a1c;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  pointer-events: none;
}

.lib-page,
.art-page {
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  background: #fff;
}

.lib-banner {
  position: relative;
  margin: 10px 10px 0;
  border: 2px solid #e8c37a;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.lib-banner-img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}

.lib-back,
.art-back {
  border: 0;
  background: transparent;
  color: #8a4b1e;
  font-size: 15px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
}

.lib-back {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 2;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: #4a3424;
}

.lib-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 14px 12px 28px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.lib-empty {
  grid-column: 1 / -1;
  padding: 48px 12px;
  text-align: center;
  color: #b08960;
  font-size: 14px;
}

.lib-item {
  min-width: 0;
  display: block;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  background: transparent;
  border: 0;
  padding: 0;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.lib-cover {
  display: block;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 8px;
  background: #f3efe6;
}

.lib-name {
  margin-top: 8px;
  color: #4a3424;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.art-page {
  padding: 12px 16px 40px;
  box-sizing: border-box;
}

.art-back {
  margin: 4px 0 12px;
  padding: 0;
}

.art-title {
  margin: 0 0 8px;
  color: #2d2118;
  font-size: 22px;
  line-height: 1.4;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.art-time {
  margin: 0 0 18px;
  color: #9a7b5c;
  font-size: 13px;
}

.art-body {
  color: #4a3424;
  font-size: 15px;
  line-height: 1.8;
  overflow-x: hidden;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.art-body img,
.art-body video,
.art-body table {
  max-width: 100% !important;
  height: auto !important;
}

.art-body p {
  margin: 0 0 12px;
}

.art-body * {
  max-width: 100%;
  box-sizing: border-box;
}

.home-fab {
  position: fixed;
  right: 14px;
  bottom: calc(152px + env(safe-area-inset-bottom));
  z-index: 80;
  width: 76px;
  height: 76px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.25;
  font-family: inherit;
  text-align: center;
  background: linear-gradient(180deg, #ffd76a 0%, #ffb03a 52%, #f08c16 100%);
  box-shadow: 0 6px 16px rgba(200, 100, 20, 0.38);
  cursor: pointer;
}

.home-fab:active {
  transform: scale(0.96);
}

body[data-page="home"] .home-fab {
  display: none;
}

@media (min-width: 768px) {
  html,
  body,
  body[data-page="home"],
  body[data-page="done"],
  body[data-page="lesson"],
  body[data-page="library"],
  body[data-page="article"] {
    background: #1c1c1c;
  }

  .page-fixed.active {
    width: 390px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.45);
  }

  #page-lesson.active,
  #page-library.active,
  #page-article.active {
    width: 390px;
    margin: 0 auto;
    min-height: 100vh;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.45);
    overflow-x: hidden;
  }

  #page-lesson.active {
    background: #388eff;
  }

  #page-library.active,
  #page-article.active {
    background: #fff;
  }

  .home-fab {
    right: calc(50% - 195px + 14px);
  }
}
