:root {
  --blue: #0d477c;
  --blue-deep: #0a335d;
  --paper: #f6eedc;
  --paper-soft: #fff8eb;
  --gold: #b98412;
  --ink: #2f2d2a;
  --muted: #74706a;
  --line: rgba(84, 72, 48, 0.14);
  --shadow: 0 8px 24px rgba(40, 34, 18, 0.14);
  --tibetan: "Microsoft Himalaya", "Kailasa", "Noto Serif Tibetan", "Qomolangma-Uchen Sarchen", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: #e8e0cf;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 460px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--paper) url("./assets/images/all_bg.png") center top / cover repeat-y;
  box-shadow: 0 0 36px rgba(0, 0, 0, 0.18);
  position: relative;
  overflow-x: hidden;
}

.loading-screen {
  min-height: 100vh;
  display: grid;
  place-content: center;
  gap: 18px;
  text-align: center;
  color: white;
  background: var(--blue) url("./assets/images/homebg_2.png") center top / cover no-repeat;
}

.loading-screen img {
  width: min(320px, 84vw);
}

.page {
  min-height: 100vh;
  padding-bottom: 92px;
}

.home-header,
.blue-header {
  color: white;
  background: var(--blue) url("./assets/images/homebg_2.png") center top / cover no-repeat;
}

.home-header {
  min-height: 248px;
  padding: 74px 18px 24px;
}

.blue-header {
  min-height: 154px;
  padding: 58px 16px 18px;
}

.header-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  width: min(315px, calc(100% - 58px));
  height: auto;
  display: block;
}

.menu-button,
.back-button,
.close-button {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
}

.menu-button {
  width: 46px;
  height: 46px;
  margin-left: auto;
  display: grid;
  place-items: center;
}

.menu-lines,
.menu-lines::before,
.menu-lines::after {
  width: 32px;
  height: 4px;
  border-radius: 4px;
  display: block;
  background: currentColor;
  content: "";
}

.menu-lines {
  position: relative;
}

.menu-lines::before,
.menu-lines::after {
  position: absolute;
  left: 0;
}

.menu-lines::before {
  top: -11px;
}

.menu-lines::after {
  top: 11px;
}

.search-form {
  margin-top: 28px;
  height: 58px;
  border-radius: 999px;
  background: #eeeadd;
  display: grid;
  grid-template-columns: 44px 1fr 76px;
  align-items: center;
  padding: 0 10px 0 20px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.search-form.compact {
  margin-top: 18px;
  height: 42px;
  grid-template-columns: 30px 1fr 55px;
  padding-left: 13px;
}

.search-icon {
  width: 24px;
  opacity: 0.46;
}

.search-form input {
  border: 0;
  min-width: 0;
  outline: 0;
  background: transparent;
  color: #222;
  font-size: 18px;
}

.search-form.compact input {
  font-size: 14px;
}

.search-form button {
  border: 0;
  background: transparent;
  color: #151515;
  font-size: 20px;
  font-weight: 700;
}

.search-form.compact button {
  font-size: 14px;
}

.category-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 24px 16px 12px;
  text-align: center;
}

.category-card {
  border: 0;
  background: transparent;
  color: #504d49;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 8px 2px;
  font-size: 20px;
}

.category-card img {
  height: 46px;
  width: 46px;
  object-fit: contain;
}

.book-block {
  padding: 58px 24px 28px;
  text-align: center;
}

.book-title {
  margin: 0 0 18px;
  font-size: 28px;
  letter-spacing: 0;
}

.book-meta {
  margin: 10px 0;
  color: #6d6961;
  font-size: 20px;
}

.primary-button {
  border: 0;
  width: 100%;
  min-height: 58px;
  border-radius: 999px;
  color: white;
  background: var(--gold);
  box-shadow: 0 5px 14px rgba(129, 86, 12, 0.22);
  font-size: 24px;
  margin: 24px 0 18px;
}

.book-desc {
  color: #59554e;
  font-family: var(--tibetan);
  font-size: 25px;
  line-height: 1.55;
  text-align: left;
  max-height: 220px;
  overflow: hidden;
  position: relative;
}

.book-desc.expanded {
  max-height: none;
}

.text-link {
  border: 0;
  background: transparent;
  color: var(--gold);
  font-weight: 700;
  padding: 8px 0;
}

.topbar {
  height: 116px;
  display: grid;
  grid-template-columns: 58px 1fr 58px;
  align-items: end;
  padding: 0 12px 20px;
}

.topbar.plain {
  background: transparent;
  color: #111;
}

.topbar-title {
  text-align: center;
  font-size: 28px;
  font-weight: 600;
}

.back-button {
  width: 46px;
  height: 46px;
  font-size: 44px;
  line-height: 1;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: center;
  min-height: 48px;
  background: rgba(255, 250, 236, 0.72);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 4;
  backdrop-filter: blur(8px);
}

.tabs.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tab {
  border: 0;
  background: transparent;
  color: #504d48;
  min-height: 48px;
  font-size: 15px;
  position: relative;
}

.tab.active {
  color: var(--gold);
  font-weight: 700;
}

.tab.active::after {
  content: "";
  position: absolute;
  width: 28px;
  height: 3px;
  border-radius: 3px;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  background: var(--gold);
}

.content {
  padding: 14px 14px 24px;
}

.result-line {
  color: #726d64;
  font-size: 14px;
  margin: 0 2px 10px;
}

.card-list {
  display: grid;
  gap: 12px;
}

.resource-card,
.name-card,
.media-card,
.detail-card {
  background: rgba(255, 248, 235, 0.94);
  border: 1px solid rgba(128, 104, 60, 0.09);
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(73, 58, 31, 0.08);
}

.resource-card {
  border: 0;
  width: 100%;
  text-align: left;
  padding: 15px 16px;
}

.resource-card h3,
.name-card h3 {
  margin: 0 0 10px;
  font-family: var(--tibetan);
  font-size: 20px;
  font-weight: 500;
  color: #24211e;
}

.resource-card p,
.name-card p {
  margin: 7px 0;
  color: #393632;
  font-size: 13px;
  line-height: 1.5;
}

.resource-card .intro {
  margin-top: 12px;
  color: #8a857c;
  font-family: var(--tibetan);
  font-size: 16px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.load-more {
  width: 100%;
  min-height: 44px;
  margin: 14px 0 4px;
  border: 1px solid rgba(185, 132, 18, 0.25);
  color: var(--gold);
  background: rgba(255, 250, 238, 0.7);
  border-radius: 999px;
}

.empty {
  padding: 38px 16px;
  text-align: center;
  color: var(--muted);
}

.detail-card {
  padding: 26px 22px;
  margin: 6px 0 18px;
}

.detail-card h2 {
  margin: 0 0 20px;
  text-align: center;
  font-size: 28px;
}

.detail-names {
  display: grid;
  gap: 9px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
  color: #4c4943;
}

.detail-names strong {
  color: #292723;
}

.detail-cover {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: 8px;
  background: #f1e8d5;
  margin-bottom: 18px;
}

.section-title {
  text-align: center;
  font-size: 24px;
  margin: 8px 0 20px;
}

.rich-text {
  color: #59554e;
  font-family: var(--tibetan);
  font-size: 22px;
  line-height: 1.54;
  overflow-wrap: anywhere;
}

.rich-text .ld,
.latin {
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
}

.gallery {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.gallery figure {
  margin: 0;
}

.gallery img {
  width: 100%;
  border-radius: 8px;
  display: block;
}

.gallery figcaption {
  color: #6e675d;
  font-size: 13px;
  line-height: 1.45;
  padding-top: 7px;
}

.name-tools {
  display: flex;
  gap: 8px;
  padding: 13px 14px 0;
}

.name-tools input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 250, 238, 0.82);
  height: 42px;
  padding: 0 16px;
  outline: 0;
}

.name-card {
  padding: 14px 16px;
}

.audio-hero {
  padding: 22px 18px 18px;
  text-align: center;
}

.audio-disc {
  width: 168px;
  height: 168px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: var(--shadow);
}

.player-panel {
  background: rgba(255, 248, 235, 0.94);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.player-panel h2 {
  margin: 0 0 12px;
  font-size: 18px;
  line-height: 1.4;
}

.player-panel audio,
.player-panel video {
  width: 100%;
  display: block;
}

.media-card {
  width: 100%;
  border: 0;
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 12px;
  padding: 12px;
  text-align: left;
  align-items: center;
}

.media-card.active {
  outline: 2px solid rgba(185, 132, 18, 0.42);
}

.media-thumb {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  object-fit: cover;
  background: #eadfca;
  display: grid;
  place-items: center;
}

.media-thumb img {
  max-width: 30px;
  max-height: 30px;
}

.media-thumb .cover-thumb {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: cover;
  border-radius: inherit;
}

.media-title {
  margin: 0 0 5px;
  font-size: 15px;
  line-height: 1.35;
}

.media-meta {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 460px);
  height: 82px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: rgba(255, 252, 241, 0.96);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  z-index: 10;
  box-shadow: 0 -4px 18px rgba(65, 53, 28, 0.08);
}

.nav-button {
  border: 0;
  background: transparent;
  color: #72706a;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 4px;
  font-size: 13px;
  min-width: 0;
}

.nav-button img {
  width: 27px;
  height: 27px;
  object-fit: contain;
}

.nav-button.active {
  color: #77529a;
  font-weight: 700;
}

.drawer-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  z-index: 20;
  display: flex;
  justify-content: center;
}

.drawer {
  width: min(100%, 460px);
  display: flex;
  justify-content: flex-end;
}

.drawer-panel {
  width: 78%;
  max-width: 330px;
  min-height: 100%;
  background: var(--paper-soft);
  padding: 42px 22px;
  box-shadow: -12px 0 28px rgba(0, 0, 0, 0.18);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}

.drawer-head h2 {
  margin: 0;
  font-size: 22px;
}

.close-button {
  color: #292723;
  font-size: 28px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.stat {
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  border: 1px solid var(--line);
}

.stat strong {
  display: block;
  font-size: 22px;
  color: var(--gold);
}

.drawer-actions {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}

.drawer-actions a,
.drawer-actions button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  text-decoration: none;
  display: grid;
  place-items: center;
}

@media (max-width: 360px) {
  .search-form {
    grid-template-columns: 36px 1fr 58px;
  }

  .category-card,
  .book-meta {
    font-size: 17px;
  }

  .book-title {
    font-size: 24px;
  }

  .rich-text {
    font-size: 19px;
  }

  .bottom-nav {
    height: 76px;
  }

  .nav-button {
    font-size: 12px;
  }
}
