:root {
  font-family: "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  color: #192b28;
  background: #f6f7f3;
  font-synthesis: none;
  --ink: #192b28;
  --muted: #596b63;
  --line: #dce3dc;
  --green: #1f5145;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; }
a { color: inherit; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
:focus-visible { outline: 3px solid #9a6328; outline-offset: 4px; }
.site-header { background: #fff; border-bottom: 1px solid var(--line); }
.header-inner, .shell { width: min(1100px, calc(100% - 64px)); margin: 0 auto; }
.header-inner { display: flex; align-items: center; gap: 22px; min-height: 74px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 23px; font-weight: 750; text-decoration: none; }
.brand-mark { display: inline-block; width: 23px; height: 20px; background: linear-gradient(90deg,#4c7966 0 45%,transparent 45% 55%,#244f43 55%); border-radius: 3px 5px 5px 3px; transform: rotate(-7deg); }
.header-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; padding: 9px 17px; border: 1px solid transparent; border-radius: 8px; font-size: .9375rem; font-weight: 650; line-height: 1.35; text-decoration: none; }
.primary { color: white; background: var(--green); }
.primary:hover { background: #173f37; }
.secondary { color: var(--ink); background: #fff; border-color: var(--line); }
.secondary:hover { background: #eaf0e9; }
.shell { padding: 45px 0 64px; }
.sign-in { max-width: 420px; margin: 28px auto 0; padding: 26px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.sign-in form { display: grid; gap: 10px; margin-top: 20px; }
.sign-in input, .accounts input { min-height: 45px; min-width: 0; padding: 8px 12px; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 8px; }
.sign-in button { margin-top: 4px; }
.accounts { max-width: 750px; margin: 0 auto; }
.accounts-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; gap: 8px; }
.account-create { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: 13px; padding: 18px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.account-create h2 { grid-column: 1 / -1; font-size: 1.15rem; }
.account-create label, .dialog-actions, #reset-form { display: grid; gap: 8px; }
.account-create .button { min-height: 45px; }
.account-list { display: grid; gap: 9px; margin-top: 18px; }
.account-entry { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 13px 16px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.account-name { font-weight: 700; overflow-wrap: anywhere; }
.account-entry-action { display: flex; gap: 7px; flex-wrap: wrap; }
#password-dialog { width: min(385px, calc(100% - 24px)); padding: 20px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); }
#password-dialog::backdrop { background: #152c27a0; }
.dialog-actions { grid-auto-flow: column; justify-content: end; margin-top: 7px; }
h1, h2, h3, p { margin: 0; }
.library-intro h1 { font-size: clamp(2rem, 4vw, 3rem); font-weight: 760; letter-spacing: -.055em; }
.muted { color: var(--muted); margin-top: 6px; }
.featured { display: grid; grid-template-columns: 1.5fr 1fr; align-items: center; gap: 32px; min-height: 300px; overflow: hidden; border-radius: 16px; margin: 27px 0 39px; padding: 37px clamp(26px, 5vw, 62px); color: #fff; background: radial-gradient(ellipse at 95% 20%, #3d695b, transparent 54%), #183c36; }
.feature-copy { min-width: 0; }
.feature-label { color: #cddfd5; margin-bottom: 12px; font-size: .9375rem; }
.feature-copy h2 { max-width: 660px; overflow-wrap: anywhere; font-size: clamp(1.45rem, 3.3vw, 2.5rem); line-height: 1.35; letter-spacing: -.035em; }
.feature-meta { margin-top: 12px; color: #d9e8df; font-size: .9375rem; }
.feature-button { margin-top: 25px; background: #f1e9d4; color: #243a31; }
.feature-button:hover { background: #fff8e8; }
.feature-cover { align-self: stretch; display: grid; align-items: center; justify-items: center; }
.feature-cover img { width: min(190px, 100%); max-height: 240px; object-fit: contain; border-radius: 4px 9px 9px 4px; box-shadow: 9px 13px 28px #0d2723a8; transform: rotate(4deg); }
.collection-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 29px 0 17px; }
.collection-heading h2 { font-size: 1.35rem; white-space: nowrap; }
.search { display: flex; align-items: center; gap: 10px; width: min(320px, 100%); padding: 0 13px; background: #fff; border-radius: 8px; border: 1px solid var(--line); }
.search-icon { display: inline-block; flex: 0 0 12px; height: 12px; border: 2px solid #577166; border-radius: 50%; position: relative; }
.search-icon::after { content: ""; position: absolute; top: 8px; left: 8px; width: 6px; height: 2px; transform: rotate(45deg); background: #577166; }
.search input { min-width: 0; width: 100%; border: 0; background: transparent; padding: 11px 0; color: var(--ink); font-size: .9375rem; }
.search:focus-within { outline: 2px solid #6e8e7d; }
.search input:focus-visible { outline: 0; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(min(100%, 180px),1fr)); gap: 17px; }
.book { display: block; padding: 0; overflow: hidden; text-decoration: none; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.book:hover { border-color: #668a79; }
.book-art { display: grid; justify-items: center; align-items: center; height: 205px; padding: 13px; background: #e9eee7; }
.book-art img { display: block; max-width: 100%; max-height: 100%; width: auto; height: 179px; object-fit: contain; box-shadow: 2px 4px 9px #223d3930; border-radius: 3px; }
.book-title { display: block; padding: 12px 12px 5px; font-weight: 650; line-height: 1.45; overflow-wrap: anywhere; }
.book-meta { display: block; color: var(--muted); font-size: .875rem; padding: 0 12px 14px; }
.empty { padding: 24px; border: 1px dashed #b7c6bc; border-radius: 10px; text-align: center; color: var(--muted); }
.empty .button { margin-top: 12px; }
.source { display: flex; gap: 18px; align-items: center; justify-content: space-between; padding: 20px 24px; margin-top: 30px; border-radius: 10px; background: #edf1eb; border: 1px solid var(--line); }
.source h3 { font-size: 1.02rem; }
.source p { color: var(--muted); margin-top: 5px; font-size: .9375rem; }
.is-reading .site-header { display: none; }
.is-reading .shell { padding-top: max(10px, env(safe-area-inset-top)); padding-bottom: 0; }
#reader { display: flex; flex-direction: column; height: calc(100dvh - max(10px, env(safe-area-inset-top))); }
.reader-heading { flex: 0 0 auto; display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.reader-heading .button { flex-shrink: 0; }
.reader-heading h1 { flex: 1; min-width: 0; font-size: clamp(1rem, 3vw, 1.6rem); line-height: 1.35; overflow-wrap: anywhere; }
.reader-toolbar { flex: 0 0 auto; display: flex; justify-content: center; align-items: center; gap: 10px; padding: 8px 0 max(8px, env(safe-area-inset-bottom)); }
.reader-toolbar form, .zoom { display: flex; align-items: center; gap: 6px; }
.reader-toolbar input, .zoom select { width: 62px; min-height: 42px; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 8px; padding: 5px 6px; }
.zoom select { width: auto; font-size: .875rem; }
.paper { flex: 1; min-height: 0; position: relative; overflow: auto; overscroll-behavior: contain; touch-action: pan-y pinch-zoom; background: #e4ebe5; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.paper:not([data-zoom="fit"]) { touch-action: pan-x pan-y pinch-zoom; }
.page-surface { width: max-content; min-width: 100%; }
.page-surface :is(img, canvas) { display: block; margin: 0 auto; height: auto; box-shadow: 0 4px 18px #223d392b; background: white; }
.paper p { text-align: center; color: var(--muted); margin-top: 24px; }
.notice { position: fixed; z-index: 2; right: 20px; bottom: 20px; max-width: calc(100vw - 40px); border-radius: 9px; padding: 14px 18px; color: #fff; background: #213c34; box-shadow: 0 3px 12px #213c3440; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 620px) {
  .header-inner, .shell { width: calc(100% - 28px); }
  .header-inner { gap: 14px; min-height: 62px; }
  .shell { padding: 23px 0 40px; }
  .featured { grid-template-columns: 1.4fr 1fr; padding: 20px 15px; min-height: 0; gap: 13px; margin: 18px 0 22px; }
  .feature-copy h2 { font-size: 1.2rem; }
  .feature-meta { margin-top: 7px; }
  .feature-button { margin-top: 12px; }
  .collection-heading { gap: 8px; }
  .collection-heading h2 { font-size: 1.1rem; }
  .book-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
  .book-art { height: 165px; }
  .book-art img { height: 139px; }
  .source { align-items: flex-start; flex-direction: column; gap: 12px; padding: 15px; }
  .is-reading .shell { width: calc(100% - 12px); }
  .reader-heading { gap: 7px; margin-bottom: 6px; }
  .reader-heading .button { padding-inline: 10px; }
  .header-actions { flex-wrap: wrap; justify-content: flex-end; }
  .header-actions .button { padding-inline: 9px; }
  .account-create { grid-template-columns: 1fr; }
  .reader-toolbar input, .zoom select { font-size: 16px; }
  .reader-toolbar .button { min-height: 44px; }
  .paper { padding: 4px; }
}
