/* 照墟 · 宗门史（v1.1.20） */
.codex-toggle {
  position: fixed;
  right: 0;
  top: 38%;
  z-index: 60;
  writing-mode: vertical-rl;
  letter-spacing: .28em;
  padding: 14px 8px;
  border: 1px solid rgba(190, 214, 200, .38);
  border-right: 0;
  border-radius: 10px 0 0 10px;
  background: linear-gradient(180deg, rgba(20, 46, 40, .92), rgba(14, 34, 30, .96));
  color: #d8e8dc;
  font-family: inherit;
  font-size: calc(13px * var(--text-scale, 1));
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  backdrop-filter: blur(6px);
  transition: transform .18s ease, background .18s ease;
}
.codex-toggle:hover { transform: translateX(-3px); }
.codex-toggle.active { background: linear-gradient(180deg, rgba(38, 78, 66, .96), rgba(20, 46, 40, .98)); }

.codex-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  width: min(560px, 94vw);
  height: 100vh;
  padding: 14px 16px 10px;
  box-sizing: border-box;
  background: linear-gradient(180deg, #10241f 0%, #0c1c19 60%, #0a1714 100%);
  border-left: 1px solid rgba(190, 214, 200, .22);
  box-shadow: -18px 0 48px rgba(0, 0, 0, .45);
  color: #dce8de;
  transform: translateX(102%);
  transition: transform .26s cubic-bezier(.22, .7, .3, 1);
  visibility: hidden;
}
.codex-drawer.open { transform: translateX(0); visibility: visible; }

.codex-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding-bottom: 8px; border-bottom: 1px solid rgba(190, 214, 200, .16); }
.codex-head strong { display: block; font-size: calc(16px * var(--text-scale, 1)); letter-spacing: .08em; }
.codex-head small { display: block; margin-top: 3px; font-size: calc(11px * var(--text-scale, 1)); color: #8fae9d; letter-spacing: .06em; }
.codex-close { border: 0; background: transparent; color: #b8cec0; font-size: 22px; line-height: 1; cursor: pointer; padding: 2px 6px; }
.codex-close:hover { color: #fff; }

.codex-tabs { display: flex; gap: 6px; margin: 10px 0 8px; }
.codex-tabs button {
  flex: 1;
  padding: 7px 4px;
  border: 1px solid rgba(190, 214, 200, .2);
  border-radius: 8px;
  background: rgba(255, 255, 255, .03);
  color: #a9c4b4;
  font-family: inherit;
  font-size: calc(12px * var(--text-scale, 1));
  cursor: pointer;
}
.codex-tabs button.active { background: rgba(122, 178, 150, .18); border-color: rgba(160, 210, 180, .5); color: #eaf6ee; }

.codex-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.codex-hint { color: #8fae9d; font-size: calc(12px * var(--text-scale, 1)); line-height: 1.7; margin: 6px 0; }

.codex-sectbar { display: flex; flex-wrap: wrap; gap: 5px; padding-bottom: 8px; }
.codex-sect {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  border: 1px solid rgba(190, 214, 200, .18);
  border-radius: 999px;
  background: rgba(255, 255, 255, .02);
  color: #b9cfc1;
  font-family: inherit;
  font-size: calc(11.5px * var(--text-scale, 1));
  cursor: pointer;
}
.codex-sect i { font-style: normal; }
.codex-sect em { font-style: normal; font-size: .82em; color: #7fc39a; }
.codex-sect.active { border-color: rgba(160, 210, 180, .62); background: rgba(122, 178, 150, .16); color: #f0f8f2; }
.codex-sect.done { border-style: dashed; }

.codex-book { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.codex-motto { padding: 4px 2px 8px; }
.codex-motto strong { font-size: calc(15px * var(--text-scale, 1)); letter-spacing: .1em; }
.codex-motto p { margin: 4px 0 0; color: #93b3a1; font-size: calc(12px * var(--text-scale, 1)); font-style: italic; }

.codex-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 10px 40px 2px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(150, 190, 170, .4) transparent;
  mask-image: linear-gradient(180deg, transparent 0, #000 18px, #000 calc(100% - 28px), transparent 100%);
}
.codex-at-end { mask-image: none; }

.codex-passage { padding: 12px 0 14px; border-bottom: 1px dashed rgba(190, 214, 200, .14); }
.codex-era { color: #79a68f; font-size: calc(10.5px * var(--text-scale, 1)); letter-spacing: .14em; }
.codex-passage h4 { margin: 5px 0 6px; font-size: calc(14px * var(--text-scale, 1)); color: #eaf6ee; letter-spacing: .05em; }
.codex-passage h4 .codex-dissent {
  display: inline-block; margin-left: 6px; padding: 0 5px; border-radius: 4px;
  background: rgba(200, 143, 143, .22); color: #e0a8a8; font-size: .74em; font-style: normal; vertical-align: 2px;
}
.codex-passage p { margin: 0; color: #c8d8cc; font-size: calc(12.5px * var(--text-scale, 1)); line-height: 1.95; text-align: justify; }
.codex-cites { margin-top: 8px; color: #7f9d8c; font-size: calc(10.5px * var(--text-scale, 1)); }
.codex-cite {
  margin: 0 4px; padding: 2px 7px; border-radius: 999px;
  border: 1px solid rgba(150, 190, 170, .28); background: transparent;
  color: #9dc3ae; font-family: inherit; font-size: inherit; cursor: pointer;
}
.codex-cite:hover { background: rgba(122, 178, 150, .14); }

.codex-chron { flex: 1; min-height: 0; }
.codex-event { padding: 12px 0; border-bottom: 1px dashed rgba(190, 214, 200, .14); }
.codex-event h4 { margin: 5px 0 6px; font-size: calc(14px * var(--text-scale, 1)); color: #eaf6ee; }
.codex-event p { margin: 0; color: #c8d8cc; font-size: calc(12.5px * var(--text-scale, 1)); line-height: 1.95; }
.codex-sources { margin-top: 7px; color: #7f9d8c; font-size: calc(10.5px * var(--text-scale, 1)); }

.codex-cross { flex: 1; min-height: 0; overflow-y: auto; padding-bottom: 40px; }
.codex-compare { margin: 8px 0; border: 1px solid rgba(190, 214, 200, .16); border-radius: 10px; padding: 8px 10px; background: rgba(255, 255, 255, .02); }
.codex-compare summary { display: flex; justify-content: space-between; gap: 8px; cursor: pointer; color: #dce8de; font-size: calc(12.5px * var(--text-scale, 1)); }
.codex-compare summary em { font-style: normal; color: #86b39a; font-size: .86em; }
.codex-canon { margin: 8px 0; padding: 8px 10px; border-left: 2px solid #7fc39a; background: rgba(122, 178, 150, .08); border-radius: 0 8px 8px 0; }
.codex-canon b { color: #9fd8b6; font-size: calc(11px * var(--text-scale, 1)); letter-spacing: .1em; }
.codex-canon p { margin: 4px 0 0; color: #cfe0d4; font-size: calc(12px * var(--text-scale, 1)); line-height: 1.85; }
.codex-row { padding: 7px 0; border-top: 1px dashed rgba(190, 214, 200, .12); }
.codex-row b { font-size: calc(11.5px * var(--text-scale, 1)); letter-spacing: .06em; }
.codex-row span { margin-left: 6px; color: #9ab8a6; font-size: calc(11px * var(--text-scale, 1)); }
.codex-row p { margin: 4px 0 0; color: #bfd0c6; font-size: calc(12px * var(--text-scale, 1)); line-height: 1.85; }
.codex-row.dissent p { color: #d8c0a8; }

.codex-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 8px; border-top: 1px solid rgba(190, 214, 200, .16); }
.codex-foot span { color: #86a895; font-size: calc(11px * var(--text-scale, 1)); }
.codex-claim {
  padding: 8px 16px; border: 1px solid rgba(160, 210, 180, .45); border-radius: 999px;
  background: rgba(122, 178, 150, .16); color: #e6f4ea;
  font-family: inherit; font-size: calc(12px * var(--text-scale, 1)); cursor: pointer;
}
.codex-claim:disabled { opacity: .42; cursor: default; }

@media (max-width: 640px) {
  .codex-toggle { top: auto; bottom: 96px; padding: 12px 7px; }
  .codex-drawer { width: 100vw; padding: 10px 12px 8px; }
  .codex-passage p { font-size: calc(13px * var(--text-scale, 1)); line-height: 2; }
}
