:root {
  color-scheme: light;
  --paper: #f5efe3;
  --paper-quiet: #eee4d2;
  --paper-warm: #fbf7ee;
  --ink: #201b16;
  --ink-soft: #665d50;
  --ink-faint: #9a8f7e;
  --tea: #3f5a4d;
  --tea-deep: #30463c;
  --tea-pale: #d8dfd4;
  --cinnabar: #9a5846;
  --rule: rgba(72, 56, 39, 0.2);
  --shadow: rgba(70, 54, 34, 0.1);
  font-family: "Songti SC", "STSongti-SC-Regular", "STSong", "Noto Serif CJK SC",
    "Source Han Serif SC", "SimSun", "PingFang SC", serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(90, 74, 52, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.08)),
    var(--paper-warm);
  background-size: 42px 42px, 100% 100%, auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  line-break: strict;
  -webkit-text-size-adjust: 100%;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      98deg,
      rgba(47, 36, 24, 0.018) 0,
      rgba(47, 36, 24, 0.018) 1px,
      transparent 1px,
      transparent 9px
    );
  mix-blend-mode: multiply;
}

body.drawer-open {
  overflow: hidden;
}

body.app-locked .reader-topbar,
body.app-locked .page-hero,
body.app-locked main,
body.app-locked .records-view,
body.app-locked .page-footer,
body.app-locked .timer-launcher,
body.app-locked .timer-bar {
  display: none !important;
}

body:not(.app-locked) .access-gate {
  display: none;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.28em;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid rgba(63, 90, 77, 0.72);
  outline-offset: 4px;
}

button {
  font: inherit;
}

.access-gate {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(2rem, 6vw, 4.5rem) clamp(1.1rem, 4vw, 3rem);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(238, 228, 210, 0.18)),
    radial-gradient(circle at 50% 28%, rgba(63, 90, 77, 0.08), transparent 28rem);
}

.gate-inner {
  width: min(36rem, 100%);
  margin: 0 auto;
}

.gate-seal {
  display: inline-grid;
  place-items: center;
  width: 4.2rem;
  height: 4.2rem;
  margin-bottom: 1.35rem;
  border: 1px solid rgba(154, 88, 70, 0.36);
  border-radius: 50%;
  color: var(--cinnabar);
  font-family: "Kaiti SC", "STKaiti", "KaiTi", serif;
  font-size: 2rem;
  background: rgba(251, 247, 238, 0.58);
}

.access-gate h1 {
  max-width: 8em;
  margin-bottom: 1.05rem;
  color: var(--tea-deep);
  font-size: clamp(4rem, 13vw, 7.4rem);
}

.access-gate .lead {
  max-width: 21rem;
  margin-bottom: 2rem;
}

.gate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-bottom: 1rem;
}

.gate-actions button {
  min-height: 2.7rem;
  border: 1px solid rgba(63, 90, 77, 0.24);
  border-radius: 999px;
  padding: 0 1.25rem;
  background: rgba(251, 247, 238, 0.78);
  color: var(--tea);
  cursor: pointer;
}

.gate-actions button:first-child {
  background: var(--tea);
  color: var(--paper-warm);
}

.gate-actions button:hover {
  filter: brightness(1.05);
}

.gate-note {
  margin: 0;
  color: var(--ink-faint);
  font-size: 0.95rem;
}

.page-hero {
  min-height: 42svh;
  padding: 1.1rem clamp(1rem, 3vw, 2.4rem) 3.5rem;
  border-bottom: 1px solid var(--rule);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(238, 228, 210, 0.24)),
    linear-gradient(115deg, rgba(63, 90, 77, 0.08), transparent 52%),
    var(--paper-warm);
}

.reader-topbar {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 0.75rem);
  left: 50%;
  z-index: 20;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: min(42rem, calc(100% - 2rem));
  margin: 0;
  min-height: 3.15rem;
  padding: 0.42rem 0.45rem 0.42rem 0.82rem;
  border: 1px solid rgba(63, 90, 77, 0.2);
  border-radius: 999px;
  background: rgba(251, 247, 238, 0.86);
  box-shadow: 0 14px 34px rgba(70, 54, 34, 0.09);
  backdrop-filter: blur(16px);
}

.current-book-button,
.topbar-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.2rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--tea);
  cursor: pointer;
  white-space: nowrap;
}

.current-book-button {
  flex: 1;
  min-width: 0;
  justify-content: flex-start;
  gap: 0.55rem;
  padding: 0 0.55rem;
  text-align: left;
}

.current-book-button span {
  color: var(--ink-faint);
  font-size: 0.82rem;
}

.current-book-button strong {
  min-width: 0;
  overflow: hidden;
  color: var(--tea-deep);
  font-family: "Kaiti SC", "STKaiti", "KaiTi", serif;
  font-size: clamp(1.02rem, 2vw, 1.16rem);
  font-weight: 500;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.topbar-button {
  padding: 0 0.8rem;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.current-book-button:hover,
.topbar-button:hover,
.topbar-button.active {
  background: var(--tea-pale);
}

.hero-inner {
  width: min(42rem, 100%);
  margin: clamp(5.5rem, 10vh, 7.2rem) auto 0;
}

.eyebrow {
  margin: 0 0 1rem;
  color: var(--cinnabar);
  font-family: "Kaiti SC", "STKaiti", "KaiTi", serif;
  font-size: 1.1rem;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-block-start: 0;
}

h1 {
  margin-block-end: 1.2rem;
  color: var(--ink);
  font-size: clamp(4.1rem, 12vw, 8.7rem);
  font-weight: 500;
  line-height: 0.96;
  letter-spacing: 0;
}

.lead {
  max-width: 24rem;
  margin-block-end: 2rem;
  color: var(--ink-soft);
  font-family: "Kaiti SC", "STKaiti", "KaiTi", serif;
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  line-height: 1.8;
}

main {
  width: 100%;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 24;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(32, 27, 22, 0.26);
  cursor: default;
}

.drawer-panel {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 4.6rem);
  right: max(1rem, env(safe-area-inset-right, 0px));
  width: min(25rem, calc(100% - 2rem));
  max-height: calc(100svh - env(safe-area-inset-top, 0px) - 6rem);
  overflow: auto;
  padding: clamp(1rem, 3vw, 1.25rem);
  border: 1px solid rgba(63, 90, 77, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.06)),
    rgba(251, 247, 238, 0.96);
  box-shadow: 0 24px 70px rgba(32, 27, 22, 0.22);
  backdrop-filter: blur(18px);
}

.drawer-panel header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.drawer-panel .eyebrow {
  margin-bottom: 0.3rem;
  font-size: 0.92rem;
}

.drawer-panel h2 {
  margin: 0;
  color: var(--tea-deep);
  font-size: clamp(1.6rem, 5vw, 2.1rem);
  font-weight: 500;
  line-height: 1.18;
}

.drawer-close,
.drawer-actions button,
.book-list button {
  min-height: 2.45rem;
  border: 1px solid rgba(63, 90, 77, 0.2);
  border-radius: 8px;
  background: rgba(251, 247, 238, 0.7);
  color: var(--tea);
  cursor: pointer;
}

.drawer-close {
  flex: 0 0 auto;
  min-height: 2.15rem;
  padding: 0 0.75rem;
  border-radius: 999px;
}

.book-list {
  display: grid;
  gap: 0.6rem;
}

.book-entry {
  display: grid;
  gap: 0.45rem;
}

.book-list button {
  display: grid;
  gap: 0.18rem;
  justify-items: start;
  padding: 0.7rem 0.85rem;
  text-align: left;
}

.chapter-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
  padding-left: 0.55rem;
}

.chapter-list button {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 2.05rem;
  padding: 0.42rem 0.58rem;
  border-color: rgba(72, 56, 39, 0.16);
  background: rgba(255, 255, 255, 0.28);
}

.book-list button span {
  color: var(--tea-deep);
  font-family: "Kaiti SC", "STKaiti", "KaiTi", serif;
  font-size: 1.18rem;
}

.chapter-list button span {
  overflow: hidden;
  max-width: 100%;
  color: var(--ink-soft);
  font-family: "Songti SC", "STSongti-SC-Regular", "STSong", "Noto Serif CJK SC",
    "Source Han Serif SC", "SimSun", "PingFang SC", serif;
  font-size: 0.92rem;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-list button small {
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.45;
}

.book-list button:hover,
.book-list button.active {
  border-color: rgba(63, 90, 77, 0.34);
  background: rgba(216, 223, 212, 0.78);
}

.book-list button.recording {
  box-shadow: inset 0 0 0 1px rgba(63, 90, 77, 0.4);
}

.chapter-list button.active,
.chapter-list button.cursor {
  border-color: rgba(63, 90, 77, 0.34);
  background: rgba(216, 223, 212, 0.62);
}

.chapter-list button.cursor span::after {
  content: " · 上次";
  color: var(--cinnabar);
  font-size: 0.78em;
}

.chapter-count-badge {
  align-self: center;
  justify-self: end;
  border-radius: 999px;
  background: rgba(63, 90, 77, 0.11);
  color: var(--tea);
  padding: 0.12rem 0.42rem;
  font-size: 0.72rem;
  line-height: 1.35;
  white-space: nowrap;
}

.drawer-actions {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.85rem;
}

.drawer-actions button {
  background: rgba(216, 223, 212, 0.54);
  color: var(--tea-deep);
}

.view-tabs {
  display: none;
}

.account-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  min-height: 2.45rem;
  padding: 0.62rem 0.65rem 0.62rem 0.85rem;
  border: 1px solid rgba(63, 90, 77, 0.2);
  border-radius: 8px;
  background: rgba(251, 247, 238, 0.72);
  color: var(--ink-soft);
}

.account-chip[data-state="signed-in"] {
  border-color: rgba(63, 90, 77, 0.3);
  color: var(--ink);
}

.account-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
}

.account-chip button,
.auth-close,
.auth-tabs button,
.auth-submit,
.auth-empty button {
  min-height: 2rem;
  border: 1px solid rgba(63, 90, 77, 0.22);
  border-radius: 999px;
  background: rgba(251, 247, 238, 0.74);
  color: var(--tea);
  padding: 0 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}

.account-chip button {
  background: var(--tea);
  color: var(--paper-warm);
  font-size: 0.86rem;
}

.account-chip button:hover,
.auth-close:hover,
.auth-tabs button:hover,
.auth-submit:hover,
.auth-empty button:hover,
.drawer-close:hover,
.drawer-actions button:hover {
  filter: brightness(1.05);
}

.account-chip button:disabled,
.auth-submit:disabled {
  cursor: default;
  opacity: 0.7;
  filter: none;
}

.referral-card {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.75rem;
  padding: 0.85rem;
  border: 1px solid rgba(63, 90, 77, 0.18);
  border-radius: 8px;
  background: rgba(216, 223, 212, 0.34);
}

.referral-card span {
  color: var(--ink-faint);
  font-size: 0.82rem;
}

.referral-card strong {
  color: var(--tea-deep);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 1.36rem;
  letter-spacing: 0.08em;
}

.referral-card button {
  width: fit-content;
  min-height: 2.1rem;
  border: 1px solid rgba(63, 90, 77, 0.22);
  border-radius: 999px;
  background: var(--tea);
  color: var(--paper-warm);
  padding: 0 0.82rem;
  cursor: pointer;
}

.timer-launcher,
.timer-bar {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 0.85rem);
  z-index: 8;
  width: min(44rem, calc(100% - 1.5rem));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.58rem 0.68rem 0.58rem 0.9rem;
  border: 1px solid rgba(63, 90, 77, 0.22);
  border-radius: 999px;
  background: rgba(48, 70, 60, 0.92);
  color: var(--paper-warm);
  box-shadow: 0 14px 34px rgba(32, 27, 22, 0.15);
  backdrop-filter: blur(18px);
}

.timer-launcher {
  width: min(34rem, calc(100% - 1.5rem));
  background: rgba(251, 247, 238, 0.88);
  color: var(--ink);
}

.timer-launcher[data-state="idle"] {
  border-color: rgba(63, 90, 77, 0.24);
  background: rgba(251, 247, 238, 0.9);
}

.timer-launcher > div,
.timer-bar > div:first-child {
  min-width: 0;
}

.timer-bar[data-status="active"] {
  border-color: rgba(63, 90, 77, 0.36);
  background: rgba(48, 70, 60, 0.94);
}

.timer-bar[data-status="saved"] {
  background: rgba(63, 90, 77, 0.92);
}

.timer-launcher strong,
.timer-bar strong {
  display: block;
  margin-bottom: 0.12rem;
  font-size: clamp(1.08rem, 2.3vw, 1.28rem);
  font-weight: 700;
  line-height: 1.25;
}

.timer-launcher strong {
  color: var(--tea-deep);
}

.timer-bar strong {
  color: #fff7ed;
}

.timer-launcher span,
.timer-bar span {
  color: rgba(251, 247, 238, 0.76);
  font-size: 0.9rem;
}

.timer-launcher span {
  color: var(--ink-soft);
}

.timer-error {
  display: block;
  min-height: 1.2rem;
  color: var(--cinnabar) !important;
}

.timer-error:empty {
  display: none;
}

.timer-stats {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.auto-scroll-control {
  display: inline-grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 0.45rem;
  min-height: 2rem;
  padding: 0.2rem 0.28rem;
  border-radius: 999px;
  background: rgba(251, 247, 238, 0.1);
  white-space: nowrap;
}

.auto-scroll-control select {
  min-height: 1.8rem;
  border: 1px solid rgba(251, 247, 238, 0.2);
  border-radius: 999px;
  background: rgba(251, 247, 238, 0.12);
  color: var(--paper-warm);
  font: inherit;
  font-size: 0.9rem;
  padding: 0 1.6rem 0 0.65rem;
  cursor: pointer;
}

.auto-scroll-control select:focus-visible {
  outline: 2px solid rgba(251, 247, 238, 0.72);
  outline-offset: 2px;
}

.speed-cycle-button {
  display: none;
  min-height: 1.8rem;
  border: 1px solid rgba(251, 247, 238, 0.2);
  border-radius: 999px;
  background: rgba(251, 247, 238, 0.12);
  color: var(--paper-warm);
  font: inherit;
  font-size: 0.9rem;
  padding: 0 0.65rem;
  cursor: pointer;
  white-space: nowrap;
}

.auto-scroll-toggle {
  min-height: 1.8rem;
  border: 1px solid rgba(251, 247, 238, 0.2);
  border-radius: 999px;
  background: rgba(251, 247, 238, 0.12);
  color: var(--paper-warm);
  font: inherit;
  font-size: 0.9rem;
  padding: 0 0.75rem;
  cursor: pointer;
  white-space: nowrap;
}

.speed-cycle-button:active,
.auto-scroll-toggle[aria-pressed="true"] {
  background: rgba(251, 247, 238, 0.18);
}

.speed-cycle-button:hover,
.auto-scroll-toggle:hover {
  filter: brightness(1.06);
}

.timer-stats span {
  min-width: 4rem;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  background: rgba(251, 247, 238, 0.12);
  color: var(--paper-warm);
  font-size: 1.08rem;
  font-weight: 700;
  text-align: center;
}

.timer-launcher button,
.timer-stats button {
  min-height: 2.35rem;
  border: 1px solid rgba(63, 90, 77, 0.24);
  border-radius: 999px;
  background: var(--tea);
  color: var(--paper-warm);
  padding: 0 1rem;
  cursor: pointer;
  white-space: nowrap;
}

.timer-stats button {
  border-color: rgba(251, 247, 238, 0.2);
  background: rgba(251, 247, 238, 0.14);
}

.timer-launcher button:hover,
.timer-stats button:hover {
  filter: brightness(1.06);
}

.timer-launcher button:disabled,
.timer-stats button:disabled,
.auto-scroll-toggle:disabled {
  cursor: default;
  filter: none;
  opacity: 0.72;
}

.toast-region {
  position: fixed;
  left: 50%;
  bottom: 5.35rem;
  z-index: 11;
  width: min(34rem, calc(100% - 2rem));
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  padding: 0.75rem 0.95rem;
  border: 1px solid rgba(63, 90, 77, 0.24);
  border-radius: 8px;
  background: rgba(251, 247, 238, 0.94);
  color: var(--ink);
  box-shadow: 0 18px 42px rgba(32, 27, 22, 0.16);
  backdrop-filter: blur(18px);
}

.toast strong,
.toast span {
  display: block;
}

.toast strong {
  color: var(--tea);
  font-weight: 600;
}

.toast span {
  margin-top: 0.18rem;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.auth-dialog {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(32, 27, 22, 0.34);
  backdrop-filter: blur(10px);
}

.auth-card {
  width: min(29rem, 100%);
  max-height: calc(100svh - 2rem);
  overflow: auto;
  padding: clamp(1.1rem, 3vw, 1.55rem);
  border: 1px solid rgba(63, 90, 77, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.06)),
    var(--paper-warm);
  box-shadow: 0 24px 70px rgba(32, 27, 22, 0.24);
}

.auth-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.auth-card .eyebrow {
  margin-bottom: 0.35rem;
  font-size: 0.95rem;
}

.auth-card h2 {
  margin: 0;
  color: var(--tea);
  font-size: clamp(1.8rem, 6vw, 2.35rem);
  font-weight: 500;
  line-height: 1.16;
}

.auth-close {
  flex: 0 0 auto;
  min-height: 2.15rem;
  background: transparent;
}

.auth-intro {
  margin: 0 0 1.1rem;
  color: var(--ink-soft);
  font-size: 0.98rem;
  line-height: 1.75;
  text-wrap: pretty;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  padding: 0.3rem;
  border: 1px solid rgba(63, 90, 77, 0.16);
  border-radius: 999px;
  background: rgba(238, 228, 210, 0.54);
}

.auth-tabs button {
  border: 0;
  background: transparent;
}

.auth-tabs button.active {
  background: var(--tea);
  color: var(--paper-warm);
}

.auth-error {
  min-height: 1.4rem;
  margin: 0 0 0.65rem;
  color: var(--cinnabar);
  font-size: 0.92rem;
  line-height: 1.5;
}

.auth-form {
  display: grid;
  gap: 0.82rem;
}

.auth-field {
  display: grid;
  gap: 0.35rem;
}

.auth-field span {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.auth-field input {
  width: 100%;
  min-height: 2.7rem;
  border: 1px solid rgba(63, 90, 77, 0.22);
  border-radius: 8px;
  background: rgba(255, 252, 245, 0.78);
  color: var(--ink);
  font: inherit;
  padding: 0 0.85rem;
}

.auth-field input:focus {
  border-color: rgba(63, 90, 77, 0.52);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(63, 90, 77, 0.11);
}

#registerReferralCode {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-submit {
  min-height: 2.65rem;
  margin-top: 0.25rem;
  background: var(--tea);
  color: var(--paper-warm);
}

.sutra-section {
  position: relative;
  padding: clamp(4.5rem, 9vw, 8rem) clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--rule);
}

.section-kicker,
.sutra-section h2,
.scripture,
.page-footer {
  width: min(43rem, 100%);
  margin-inline: auto;
}

.section-kicker {
  display: flex;
  align-items: center;
  gap: 0.95rem;
  margin-bottom: 1.25rem;
  color: var(--ink-soft);
}

.section-kicker span {
  width: 2.6rem;
  height: 2.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(63, 90, 77, 0.34);
  border-radius: 50%;
  color: var(--tea);
  font-family: "Kaiti SC", "STKaiti", "KaiTi", serif;
  font-size: 1.35rem;
}

.section-kicker small {
  font-size: 0.95rem;
}

.sutra-section h2 {
  margin-bottom: 0.95rem;
  color: var(--tea);
  font-size: clamp(2.45rem, 7vw, 5.2rem);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: 0;
}

.version-block {
  width: min(43rem, 100%);
  margin: 0 auto clamp(2.7rem, 5vw, 4.1rem);
  color: var(--ink-soft);
}

.version-block > p {
  margin: 0 0 0.65rem;
  color: var(--tea-deep);
  font-size: clamp(0.96rem, 1.5vw, 1.05rem);
  line-height: 1.7;
}

.version-block details {
  width: fit-content;
  max-width: 100%;
}

.version-block summary {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0 0.78rem;
  border: 1px solid rgba(63, 90, 77, 0.2);
  border-radius: 999px;
  background: rgba(251, 247, 238, 0.58);
  color: var(--tea);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  user-select: none;
}

.version-block summary::-webkit-details-marker {
  display: none;
}

.version-block details[open] {
  width: 100%;
}

.version-block details[open] summary {
  margin-bottom: 0.7rem;
  background: var(--tea-pale);
}

.version-block details > div {
  padding: 0.85rem 1rem;
  border: 1px solid rgba(63, 90, 77, 0.16);
  border-radius: 8px;
  background: rgba(251, 247, 238, 0.54);
}

.version-block details p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.94rem;
  line-height: 1.75;
  text-wrap: pretty;
}

.version-block details p + p {
  margin-top: 0.45rem;
}

.scripture {
  border-left: 1px solid var(--rule);
  padding-left: clamp(1.1rem, 3vw, 2.2rem);
}

.chapter {
  margin-block: 0 clamp(2.4rem, 5vw, 4.25rem);
}

.chapter h3 {
  margin-bottom: 1.15rem;
  color: #7c5f46;
  font-family: "Kaiti SC", "STKaiti", "KaiTi", serif;
  font-size: clamp(1.15rem, 2.8vw, 1.45rem);
  font-weight: 500;
  line-height: 1.6;
}

.scripture p {
  margin: 0 0 1.55rem;
  color: var(--ink);
  font-size: clamp(1.36rem, 2.25vw, 1.62rem);
  font-weight: 400;
  line-height: 2.52;
  line-break: strict;
  text-wrap: pretty;
  hanging-punctuation: allow-end;
}

.scripture ruby {
  ruby-position: over;
  white-space: nowrap;
}

.ruby-word {
  position: relative;
  display: inline-block;
  max-width: 100%;
  white-space: nowrap;
  break-inside: avoid;
  line-height: 1;
  vertical-align: baseline;
}

.ruby-word--cells {
  display: inline-block;
}

.ruby-cell {
  position: relative;
  display: inline-block;
  width: 1em;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  vertical-align: baseline;
}

.ruby-base {
  white-space: nowrap;
}

.ruby-cell .ruby-base {
  display: block;
  width: 1em;
}

.ruby-note {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.16em);
  transform: translateX(-50%);
  white-space: nowrap;
  color: var(--cinnabar);
  font-family: "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  font-size: 0.46em;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
  opacity: 0.78;
  pointer-events: none;
  user-select: none;
}

.scripture rt {
  color: var(--cinnabar);
  font-family: "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  font-size: 0.46em;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
  opacity: 0.78;
  user-select: text;
}

.text-line {
  display: block;
  max-width: 100%;
  overflow-wrap: normal;
  word-break: normal;
  line-break: strict;
  text-wrap: pretty;
  hanging-punctuation: allow-end;
}

.text-unit {
  position: relative;
}

.text-unit--line-group {
  display: block;
}

.unit-anchor-dot {
  position: absolute;
  top: 0.95em;
  left: clamp(-2rem, -3vw, -1.24rem);
  display: grid;
  place-items: center;
  width: 1.15rem;
  height: 1.15rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--cinnabar);
  cursor: pointer;
  opacity: 0.3;
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    background-color 180ms ease;
}

.unit-anchor-dot span {
  width: 0.34rem;
  height: 0.34rem;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 1px rgba(154, 88, 70, 0.12);
}

.annotation-unit:hover .unit-anchor-dot,
.unit-anchor-dot:focus-visible {
  background: rgba(154, 88, 70, 0.08);
  opacity: 0.9;
  transform: scale(1.08);
}

.annotation-unit:focus-within .unit-anchor-dot {
  opacity: 0.9;
}

#tao-reading .scripture p {
  margin-bottom: 0;
}

#tao-reading .text-line + .text-line {
  margin-top: 0.24rem;
}

#tao-reading .text-unit--line-group + .text-unit--line-group {
  margin-top: 0.24rem;
}

.annotation-sheet {
  position: fixed;
  inset: 0;
  z-index: 26;
}

body.annotation-open {
  overflow: hidden;
}

.annotation-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(32, 27, 22, 0.16);
  cursor: default;
}

.annotation-panel {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 4.6rem);
  right: max(1rem, env(safe-area-inset-right, 0px));
  width: min(28rem, calc(100% - 2rem));
  max-height: calc(100svh - env(safe-area-inset-top, 0px) - 6rem);
  overflow: auto;
  padding: clamp(1rem, 3vw, 1.28rem);
  border: 1px solid rgba(63, 90, 77, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.06)),
    rgba(251, 247, 238, 0.97);
  box-shadow: 0 24px 70px rgba(32, 27, 22, 0.22);
  backdrop-filter: blur(18px);
}

.annotation-panel header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.annotation-panel .eyebrow {
  margin-bottom: 0.32rem;
  font-size: 0.92rem;
}

.annotation-panel h2 {
  margin: 0;
  color: var(--tea-deep);
  font-family: "Kaiti SC", "STKaiti", "KaiTi", serif;
  font-size: clamp(1.55rem, 5vw, 2.08rem);
  font-weight: 500;
  line-height: 1.24;
  text-wrap: pretty;
}

.annotation-close {
  flex: 0 0 auto;
  min-height: 2.15rem;
  border: 1px solid rgba(63, 90, 77, 0.2);
  border-radius: 999px;
  background: rgba(251, 247, 238, 0.7);
  color: var(--tea);
  padding: 0 0.75rem;
  cursor: pointer;
}

.annotation-source {
  margin: 0 0 0.9rem;
  padding: 0.7rem 0.82rem;
  border: 1px solid rgba(72, 56, 39, 0.13);
  border-radius: 8px;
  background: rgba(238, 228, 210, 0.32);
  color: var(--ink-soft);
  font-family: "Kaiti SC", "STKaiti", "KaiTi", serif;
  font-size: 1.08rem;
  line-height: 1.8;
  text-wrap: pretty;
}

.annotation-anchor-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.36rem;
  margin: 0 0 0.9rem;
}

.annotation-anchor-tabs button,
.annotation-questions button,
.annotation-ask button {
  min-height: 2.15rem;
  border: 1px solid rgba(63, 90, 77, 0.2);
  border-radius: 999px;
  background: rgba(251, 247, 238, 0.7);
  color: var(--tea);
  padding: 0 0.72rem;
  cursor: pointer;
}

.annotation-anchor-tabs button {
  max-width: 100%;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 0.88rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.annotation-anchor-tabs button.active {
  border-color: rgba(63, 90, 77, 0.34);
  background: rgba(216, 223, 212, 0.76);
  color: var(--tea-deep);
}

.annotation-section {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.9rem;
}

.annotation-section strong {
  color: var(--tea-deep);
  font-size: 0.95rem;
  font-weight: 700;
}

.annotation-section p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.98rem;
  line-height: 1.78;
  text-wrap: pretty;
}

.annotation-term-parts {
  display: grid;
  gap: 0.48rem;
  margin-top: 0.9rem;
}

.term-part {
  display: grid;
  gap: 0.22rem;
  padding: 0.66rem 0.72rem;
  border: 1px solid rgba(63, 90, 77, 0.14);
  border-radius: 8px;
  background: rgba(216, 223, 212, 0.25);
}

.term-part strong {
  color: var(--tea-deep);
  font-size: 0.95rem;
}

.term-part span {
  color: var(--ink-soft);
  font-size: 0.92rem;
  line-height: 1.62;
}

.annotation-questions {
  display: grid;
  gap: 0.45rem;
}

.annotation-questions button {
  height: auto;
  min-height: 2.28rem;
  border-radius: 8px;
  color: var(--ink-soft);
  line-height: 1.45;
  padding-block: 0.46rem;
  text-align: left;
  white-space: normal;
}

.annotation-ask {
  display: grid;
  gap: 0.5rem;
  margin-top: 1rem;
}

.annotation-ask label {
  color: var(--tea-deep);
  font-size: 0.95rem;
  font-weight: 700;
}

.annotation-ask textarea {
  width: 100%;
  min-height: 5rem;
  resize: vertical;
  border: 1px solid rgba(63, 90, 77, 0.22);
  border-radius: 8px;
  background: rgba(255, 252, 245, 0.78);
  color: var(--ink);
  font: inherit;
  line-height: 1.65;
  padding: 0.7rem 0.78rem;
}

.annotation-ask textarea:focus {
  border-color: rgba(63, 90, 77, 0.52);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(63, 90, 77, 0.11);
}

.annotation-ask button {
  justify-self: end;
  min-width: 5rem;
  background: var(--tea);
  color: var(--paper-warm);
}

.annotation-ask button:disabled {
  cursor: default;
  opacity: 0.7;
}

.annotation-answer {
  display: grid;
  gap: 0.48rem;
  margin-top: 1rem;
  padding-top: 0.92rem;
  border-top: 1px solid rgba(72, 56, 39, 0.16);
}

.annotation-answer p {
  margin: 0;
  color: var(--ink);
  font-size: 0.98rem;
  line-height: 1.78;
  text-wrap: pretty;
}

.annotation-answer small {
  color: var(--ink-faint);
  font-size: 0.8rem;
}

.annotation-error {
  color: var(--cinnabar) !important;
}

.annotation-close:hover,
.annotation-anchor-tabs button:hover,
.annotation-questions button:hover,
.annotation-ask button:hover {
  filter: brightness(1.05);
}

.records-view {
  padding: clamp(4.5rem, 9vw, 8rem) clamp(1rem, 4vw, 3rem);
  min-height: 50vh;
}

.records-inner {
  width: min(43rem, 100%);
  margin: 0 auto;
}

.back-to-reading {
  min-height: 2.3rem;
  margin-bottom: 1.4rem;
  border: 1px solid rgba(63, 90, 77, 0.22);
  border-radius: 999px;
  background: rgba(251, 247, 238, 0.72);
  color: var(--tea);
  padding: 0 0.95rem;
  cursor: pointer;
}

.back-to-reading:hover {
  background: var(--tea-pale);
}

.records-inner h2 {
  margin-bottom: 2rem;
  color: var(--tea);
  font-size: clamp(2.3rem, 6vw, 4.3rem);
  font-weight: 500;
  line-height: 1.1;
}

.record-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0 0 1.35rem;
}

.record-filters button {
  min-height: 2.2rem;
  border: 1px solid rgba(63, 90, 77, 0.22);
  border-radius: 999px;
  background: rgba(251, 247, 238, 0.72);
  color: var(--tea);
  padding: 0 0.9rem;
  cursor: pointer;
}

.record-filters button:hover {
  background: var(--tea-pale);
}

.record-filters button.active {
  background: var(--tea);
  color: var(--paper-warm);
}

.records-list {
  display: grid;
  gap: 0.85rem;
}

.chapter-progress-panel {
  display: grid;
  gap: 0.9rem;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(63, 90, 77, 0.2);
  border-radius: 8px;
  background: rgba(216, 223, 212, 0.36);
}

.chapter-progress-panel header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.chapter-progress-panel header div {
  display: grid;
  gap: 0.2rem;
}

.chapter-progress-panel header strong {
  color: var(--tea);
  font-size: 1.08rem;
}

.chapter-progress-panel header span {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.chapter-progress-panel header > b {
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(63, 90, 77, 0.12);
  color: var(--tea-deep);
  padding: 0.22rem 0.58rem;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
}

.book-progress-grid,
.chapter-count-grid {
  display: grid;
  gap: 0.5rem;
}

.book-progress-grid {
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
}

.book-progress-card {
  display: grid;
  gap: 0.2rem;
  padding: 0.72rem 0.78rem;
  border: 1px solid rgba(63, 90, 77, 0.14);
  border-radius: 8px;
  background: rgba(251, 247, 238, 0.54);
}

.book-progress-card strong {
  color: var(--tea-deep);
  font-size: 1rem;
}

.book-progress-card span,
.book-progress-card small {
  color: var(--ink-soft);
  font-size: 0.86rem;
  line-height: 1.45;
}

.chapter-count-grid {
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
}

.chapter-count-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  min-height: 2.1rem;
  border: 1px solid rgba(72, 56, 39, 0.12);
  border-radius: 999px;
  background: rgba(251, 247, 238, 0.48);
  color: var(--ink-soft);
  padding: 0.28rem 0.62rem;
}

.chapter-count-pill.read {
  border-color: rgba(63, 90, 77, 0.2);
  background: rgba(251, 247, 238, 0.78);
  color: var(--ink);
}

.chapter-count-pill span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.88rem;
}

.chapter-count-pill b {
  color: var(--tea);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

.record-item {
  padding: 1rem 1.1rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: rgba(251, 247, 238, 0.68);
}

.record-item > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.record-item strong {
  color: var(--tea);
  font-size: 1.2rem;
}

.record-item span,
.empty-records {
  color: var(--ink-soft);
}

.auth-empty {
  display: grid;
  gap: 0.55rem;
  align-items: start;
  padding: 1.15rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: rgba(251, 247, 238, 0.62);
}

.auth-empty strong {
  color: var(--tea);
  font-size: 1.08rem;
}

.auth-empty span {
  line-height: 1.7;
}

.auth-empty button {
  width: fit-content;
  min-height: 2.25rem;
  background: var(--tea);
  color: var(--paper-warm);
}

.record-item dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
  gap: 0.7rem;
  margin: 0;
}

.record-item dt {
  color: var(--ink-faint);
  font-size: 0.8rem;
}

.record-item dd {
  margin: 0.2rem 0 0;
  color: var(--ink);
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

.page-footer {
  padding: 3rem clamp(1rem, 4vw, 3rem) 4rem;
  color: var(--ink-faint);
  font-size: 0.92rem;
  line-height: 1.8;
}

.page-footer p {
  margin-bottom: 0.45rem;
}

@media (max-width: 980px) and (min-width: 721px) {
  .hero-inner {
    margin-top: clamp(6rem, 11vh, 7.4rem);
  }
}

@media (hover: none) and (pointer: coarse) {
  .unit-anchor-dot {
    display: none;
  }

  .annotation-unit {
    cursor: pointer;
    text-decoration-line: underline;
    text-decoration-color: rgba(154, 88, 70, 0.42);
    text-decoration-thickness: 0.055em;
    text-underline-offset: 0.28em;
    text-decoration-skip-ink: auto;
  }

  .annotation-unit:active {
    color: var(--tea-deep);
    text-decoration-color: rgba(154, 88, 70, 0.7);
  }
}

@media (max-width: 720px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  .access-gate {
    align-items: start;
    padding-top: calc(env(safe-area-inset-top, 0px) + 5.3rem);
  }

  .gate-seal {
    width: 3.6rem;
    height: 3.6rem;
    margin-bottom: 1.1rem;
    font-size: 1.72rem;
  }

  .access-gate h1 {
    font-size: clamp(3.5rem, 16vw, 4.7rem);
  }

  .gate-actions button {
    flex: 1 1 8rem;
  }

  .page-hero {
    min-height: 34svh;
    padding-bottom: 2.5rem;
    overflow-x: hidden;
  }

  .reader-topbar {
    top: calc(env(safe-area-inset-top, 0px) + 0.55rem);
    width: calc(100vw - 1.2rem);
    min-height: 3rem;
    padding: 0.38rem 0.38rem 0.38rem 0.68rem;
    gap: 0.45rem;
  }

  .current-book-button {
    gap: 0.42rem;
    padding-inline: 0.35rem;
  }

  .current-book-button span {
    font-size: 0.78rem;
  }

  .current-book-button strong {
    font-size: 1.08rem;
  }

  .topbar-actions {
    gap: 0.24rem;
  }

  .topbar-button {
    min-height: 2.12rem;
    padding: 0 0.62rem;
    font-size: 0.88rem;
  }

  .hero-inner {
    margin-top: 5.7rem;
  }

  .drawer-panel {
    top: calc(env(safe-area-inset-top, 0px) + 4rem);
    right: 0.6rem;
    left: 0.6rem;
    width: auto;
    max-height: calc(100svh - env(safe-area-inset-top, 0px) - 4.8rem);
  }

  .annotation-panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 86svh;
    padding: 1rem 1rem calc(env(safe-area-inset-bottom, 0px) + 1.1rem);
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 8px 8px 0 0;
  }

  .annotation-panel h2 {
    font-size: clamp(1.42rem, 6vw, 1.85rem);
  }

  .annotation-source {
    font-size: 1rem;
  }

  .account-chip span {
    font-size: 0.86rem;
  }

  .account-chip button {
    padding-inline: 0.72rem;
  }

  .timer-launcher,
  .timer-bar {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 0.65rem);
    width: calc(100% - 1.2rem);
    border-radius: 999px;
  }

  .timer-launcher {
    align-items: center;
    gap: 0.65rem;
    padding: 0.52rem 0.58rem 0.52rem 0.78rem;
  }

  .timer-launcher strong {
    margin: 0;
    font-size: 1.02rem;
  }

  .timer-launcher span:not(.timer-error) {
    display: none;
  }

  .timer-bar {
    display: grid;
    grid-template-columns: minmax(4.8rem, 1fr) auto auto;
    align-items: center;
    gap: 0.35rem;
    border-radius: 999px;
    padding: 0.42rem 0.5rem 0.42rem 0.72rem;
  }

  .timer-bar > div:first-child {
    min-width: 0;
  }

  .timer-bar strong {
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.94rem;
  }

  .timer-bar > div:first-child span {
    display: none;
  }

  .toast-region {
    bottom: 4.7rem;
  }

  .auto-scroll-control {
    width: fit-content;
    justify-self: end;
    grid-template-columns: auto auto;
    gap: 0.28rem;
    min-height: 2rem;
    padding: 0;
    background: transparent;
  }

  .auto-scroll-control select {
    display: none;
  }

  .speed-cycle-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2rem;
    min-width: 3.35rem;
    font-size: 0.84rem;
    padding-inline: 0.55rem;
  }

  .auto-scroll-toggle {
    min-height: 2rem;
    font-size: 0.86rem;
    padding-inline: 0.62rem;
  }

  .timer-stats {
    gap: 0.3rem;
    justify-content: flex-end;
  }

  .timer-stats span {
    min-width: 3.2rem;
    padding: 0.24rem 0.42rem;
    font-size: 0.88rem;
  }

  .timer-stats button {
    min-height: 2rem;
    padding-inline: 0.62rem;
    font-size: 0.86rem;
  }

  .sutra-section {
    overflow-x: hidden;
  }

  .sutra-section h2 {
    font-size: clamp(2.2rem, 10.5vw, 2.65rem);
    overflow-wrap: anywhere;
  }

  .version-block {
    margin-bottom: 2.55rem;
  }

  .version-block > p {
    font-size: 0.96rem;
  }

  .version-block details > div {
    padding: 0.8rem 0.85rem;
  }

  .scripture {
    padding-left: 1rem;
  }

  .unit-anchor-dot {
    display: none;
  }

  .annotation-unit {
    cursor: pointer;
    text-decoration-line: underline;
    text-decoration-color: rgba(154, 88, 70, 0.42);
    text-decoration-thickness: 0.055em;
    text-underline-offset: 0.28em;
    text-decoration-skip-ink: auto;
  }

  .scripture p {
    font-size: 1.42rem;
    line-height: 2.48;
  }

  .ruby-note,
  .scripture rt {
    font-size: 0.44em;
  }

  .chapter-progress-panel {
    padding: 0.88rem;
  }

  .chapter-progress-panel header {
    gap: 0.75rem;
  }

  .chapter-count-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chapter-count-pill {
    min-height: 2rem;
    padding-inline: 0.52rem;
  }

  .chapter-count-pill span {
    font-size: 0.82rem;
  }

  .record-item > div {
    flex-direction: column;
  }

  .record-item dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
