:root {
  --paper: #f7f1e8;
  --paper-deep: #eee5d6;
  --ink: #2d2925;
  --ink-soft: #716a61;
  --line: rgba(58, 48, 39, .14);
  --orange: #dd6c43;
  --orange-dark: #bd5131;
  --teal: #185d58;
  --card: #fffcf6;
  --shadow: 0 16px 40px rgba(61, 45, 30, .10);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--paper); color: var(--ink); font-family: ui-serif, Georgia, "Noto Serif SC", "Songti SC", serif; }
button, input { font: inherit; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }

.page-shell { width: min(1180px, calc(100% - 48px)); margin: 0 auto; }
.site-header { min-height: 84px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 9px; font-size: 19px; font-weight: 700; letter-spacing: .06em; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; background: var(--orange); color: white; border-radius: 50% 47% 50% 44%; font-size: 16px; }
.main-nav { display: flex; justify-content: center; gap: clamp(15px, 3vw, 34px); margin-left: auto; }
.main-nav a { color: var(--ink-soft); font-size: 15px; transition: color .2s; }
.main-nav a:hover, .main-nav .active { color: var(--ink); font-weight: 700; }
.icon-button { display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; width: 34px; height: 34px; background: transparent; color: var(--ink); }

.hero-panel { display: grid; grid-template-columns: 1.04fr .96fr; min-height: 450px; margin: 38px 0 96px; overflow: hidden; border-radius: 3px; background: var(--teal); color: #fff9ec; box-shadow: var(--shadow); }
.hero-copy { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: clamp(38px, 7vw, 80px); padding-right: 28px; }
.eyebrow { margin: 0 0 11px; color: var(--orange); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 11px; font-weight: 750; letter-spacing: .15em; }
.hero-panel .eyebrow { color: #ffae71; }
.hero-panel h1, .page-intro h1 { margin: 0; font-size: clamp(37px, 4.1vw, 57px); line-height: 1.2; letter-spacing: .03em; }
.hero-text { max-width: 360px; margin: 22px 0 25px; color: #d9e3d4; line-height: 1.8; font-size: 15px; }
.search-box { display: flex; width: min(100%, 420px); padding: 5px; background: #fffdf8; border-radius: 3px; }
.search-box input { min-width: 0; flex: 1; border: 0; outline: 0; padding: 9px 12px; background: transparent; color: #2d2925; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 14px; }
.search-box button, .primary-link { border: 0; border-radius: 2px; padding: 10px 20px; background: var(--orange); color: white; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 14px; font-weight: 700; transition: background .2s, transform .2s; }
.search-box button:hover, .primary-link:hover { background: var(--orange-dark); transform: translateY(-1px); }
.hero-actions { display: flex; align-items: center; gap: 22px; margin-top: 23px; }
.text-action, .more-link { color: inherit; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 13px; font-weight: 700; }
.text-action span, .more-link span { padding-left: 4px; color: var(--orange); font-size: 18px; vertical-align: -1px; }
.install-hint { color: #b9cec2; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 12px; }
.hero-visual { position: relative; overflow: hidden; background: #e5a347; }
.hero-visual::after { content: ""; position: absolute; width: 88%; height: 34%; left: -3%; bottom: -12%; border-radius: 50% 50% 0 0; border-top: 28px solid #10504b; transform: rotate(-8deg); }
.sun-disc { position: absolute; top: 10%; right: 10%; width: 175px; aspect-ratio: 1; border-radius: 50%; background: #f2d278; }
.hero-visual p { position: absolute; z-index: 2; left: 11%; top: 13%; color: #5d4321; font-size: 16px; letter-spacing: .2em; writing-mode: vertical-rl; }
.book-stack { position: absolute; z-index: 3; width: 155px; height: 205px; bottom: 18%; left: 26%; border-radius: 3px 10px 10px 3px; box-shadow: 11px 10px 0 rgba(58, 51, 36, .16); }
.book-stack::after { content: ""; position: absolute; top: 0; bottom: 0; left: 24px; width: 2px; background: rgba(255,255,255,.36); }
.book-one { background: #b44939; transform: rotate(-7deg); }
.book-two { bottom: 15%; left: 53%; background: #3a4e8e; transform: rotate(8deg); }
.book-three { height: 105px; bottom: 12%; left: 33%; background: #f0e4c5; transform: rotate(-1deg); }

.content-section { margin-bottom: 82px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
.section-heading h2 { margin: 0; font-size: 28px; letter-spacing: .04em; }
.more-link { color: var(--ink-soft); }
.book-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(16px, 2vw, 27px); }
.book-card { min-width: 0; }
.book-cover { position: relative; display: flex; align-items: flex-end; min-height: 250px; overflow: hidden; padding: 18px; color: white; background: var(--cover, #555); box-shadow: 5px 7px 0 rgba(60, 43, 31, .13); transition: transform .22s, box-shadow .22s; }
.book-card:hover .book-cover { transform: translateY(-5px); box-shadow: 8px 12px 0 rgba(60, 43, 31, .14); }
.book-cover::before { content: ""; position: absolute; inset: 9px; border: 1px solid rgba(255,255,255,.52); }
.book-cover::after { content: ""; position: absolute; width: 115%; height: 34%; top: -8%; left: -8%; border-radius: 50%; background: var(--accent, rgba(255,255,255,.22)); transform: rotate(-16deg); }
.cover-subtitle, .cover-title { position: relative; z-index: 1; margin: 0; text-shadow: 0 2px 5px rgba(0,0,0,.18); }
.cover-subtitle { align-self: flex-start; margin-right: auto; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 10px; letter-spacing: .14em; }
.cover-title { margin-left: -11px; margin-bottom: 12px; font-size: clamp(22px, 2vw, 31px); letter-spacing: .1em; writing-mode: vertical-rl; height: 154px; }
.book-meta { padding-top: 14px; }
.book-meta h3 { overflow: hidden; margin: 0 0 6px; font-size: 17px; text-overflow: ellipsis; white-space: nowrap; }
.book-meta p { margin: 0; color: var(--ink-soft); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 12px; }
.tag { display: inline-block; margin: 9px 0 0; padding: 3px 7px; border: 1px solid var(--line); color: var(--ink-soft); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 11px; }

.shelf-section { padding: 47px 52px 26px; background: var(--paper-deep); }
.update-list { display: grid; grid-template-columns: 1fr 1fr; column-gap: 49px; }
.update-row { display: grid; grid-template-columns: 80px minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 59px; border-top: 1px solid var(--line); color: var(--ink-soft); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 13px; }
.update-row:nth-child(2) { border-top: 0; }
.update-row b { overflow: hidden; color: var(--ink); font-family: ui-serif, Georgia, serif; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.update-row span:last-child { font-size: 11px; }

.page-intro { padding: 82px 0 40px; border-bottom: 1px solid var(--line); }
.page-intro p:last-child { max-width: 520px; margin: 18px 0 0; color: var(--ink-soft); line-height: 1.8; }
.category-chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 34px 0 54px; }
.category-chip { border: 1px solid var(--line); border-radius: 20px; padding: 8px 17px; background: transparent; color: var(--ink-soft); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 13px; }
.category-chip.active, .category-chip:hover { border-color: var(--teal); background: var(--teal); color: white; }
.category-results { min-height: 350px; }
.muted { color: var(--ink-soft); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 13px; }

.empty-state { display: grid; place-items: center; min-height: 235px; padding: 25px; border: 1px dashed var(--line); color: var(--ink-soft); text-align: center; }
.empty-state h2 { margin: 0 0 8px; color: var(--ink); font-size: 20px; }
.empty-state p { margin: 0; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 13px; line-height: 1.7; }
.library-grid { grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); }

.about-card { max-width: 780px; margin: 58px auto 100px; padding: clamp(28px, 5vw, 55px); background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); }
.about-card h2 { margin: 0 0 20px; font-size: 28px; }
.about-card p { color: var(--ink-soft); line-height: 2; }
.about-card code { padding: 2px 5px; background: var(--paper-deep); color: var(--ink); font-family: ui-monospace, Consolas, monospace; font-size: .85em; }
.primary-link { display: inline-block; margin-top: 15px; }

.book-detail { display: grid; grid-template-columns: 260px 1fr; gap: clamp(32px, 7vw, 88px); align-items: center; padding: 80px 8% 73px; border-bottom: 1px solid var(--line); }
.book-detail .book-cover { width: 220px; min-height: 306px; }
.book-detail h1 { margin: 0 0 14px; font-size: 39px; letter-spacing: .08em; }
.book-summary { margin: 22px 0; color: var(--ink-soft); line-height: 1.9; font-size: 15px; }
.book-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.secondary-button { border: 1px solid var(--line); border-radius: 2px; padding: 10px 18px; background: transparent; color: var(--ink); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 14px; }
.secondary-button:hover { border-color: var(--teal); color: var(--teal); }
.chapter-section { max-width: 860px; margin: 50px auto 100px; }
.chapter-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0 35px; margin: 0; padding: 0; list-style: none; }
.chapter-list a { display: block; overflow: hidden; padding: 15px 3px; border-bottom: 1px solid var(--line); color: var(--ink-soft); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.chapter-list a:hover { color: var(--orange); }

.reader { max-width: 790px; min-height: 75vh; margin: 0 auto; padding: 70px 0 120px; }
.reader-header { margin-bottom: 46px; text-align: center; }
.reader-header a { color: var(--ink-soft); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 13px; }
.reader-header h1 { margin: 20px 0 8px; font-size: 32px; letter-spacing: .05em; }
.reader-header p { margin: 0; color: var(--ink-soft); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 13px; }
.reader-body { font-size: 18px; line-height: 2.15; letter-spacing: .035em; }
.reader-body p { margin: 0 0 1.5em; text-indent: 2em; }
.reader-navigation { display: flex; justify-content: space-between; gap: 15px; margin-top: 65px; padding-top: 25px; border-top: 1px solid var(--line); }
.reader-navigation a { min-width: 100px; color: var(--teal); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 14px; }
.reader-navigation a:last-child { text-align: right; }
.reader-navigation .disabled { visibility: hidden; }
.error-message { padding: 90px 25px; color: var(--ink-soft); text-align: center; }

.site-footer { display: flex; justify-content: center; gap: 9px; padding: 30px 0 38px; border-top: 1px solid var(--line); color: var(--ink-soft); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

body.dark { --paper: #22211f; --paper-deep: #2d2a26; --ink: #f1e8d9; --ink-soft: #bbb1a3; --line: rgba(242, 231, 214, .16); --card: #292724; --shadow: 0 16px 40px rgba(0, 0, 0, .26); color-scheme: dark; }
body.dark .book-cover { box-shadow: 5px 7px 0 rgba(0,0,0,.26); }

@media (max-width: 760px) {
  .page-shell { width: min(100% - 30px, 560px); }
  .site-header { min-height: 69px; gap: 13px; }
  .brand { font-size: 16px; }
  .brand-mark { width: 26px; height: 26px; font-size: 14px; }
  .main-nav { gap: 15px; }
  .main-nav a { font-size: 13px; }
  .main-nav a:nth-child(3), .main-nav a:nth-child(4) { display: none; }
  .hero-panel { grid-template-columns: 1fr; min-height: 0; margin: 22px 0 63px; }
  .hero-copy { padding: 48px 30px 39px; }
  .hero-panel h1 { font-size: 38px; }
  .hero-visual { display: none; }
  .hero-actions { align-items: flex-start; flex-direction: column; gap: 9px; }
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 27px 15px; }
  .book-cover { min-height: 219px; padding: 12px; }
  .cover-title { margin-bottom: 7px; height: 135px; font-size: 24px; }
  .shelf-section { margin-left: -15px; margin-right: -15px; padding: 37px 22px 20px; }
  .update-list { grid-template-columns: 1fr; }
  .update-row:nth-child(2) { border-top: 1px solid var(--line); }
  .update-row { grid-template-columns: 64px minmax(0, 1fr) auto; }
  .page-intro { padding: 56px 0 28px; }
  .book-detail { grid-template-columns: 1fr; justify-items: center; gap: 30px; padding: 50px 5% 49px; text-align: center; }
  .book-detail .book-cover { width: 190px; min-height: 270px; }
  .book-actions { justify-content: center; }
  .chapter-list { grid-template-columns: 1fr; }
  .reader { padding: 48px 0 90px; }
  .reader-body { font-size: 17px; line-height: 2.05; }
}

.account-area { display: flex; align-items: center; gap: 10px; }
.account-link, .admin-link { color: var(--ink-soft); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 13px; white-space: nowrap; }
.account-link:hover, .admin-link:hover { color: var(--teal); }
.admin-link { padding-left: 10px; border-left: 1px solid var(--line); color: var(--orange-dark); font-weight: 700; }
.account-card { max-width: 570px; margin: 58px auto 100px; padding: clamp(28px, 5vw, 48px); background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); }
.account-summary { display: flex; align-items: center; gap: 18px; padding-bottom: 27px; border-bottom: 1px solid var(--line); }
.account-avatar { display: grid; flex: 0 0 auto; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--teal); color: #fff9ec; font-size: 21px; font-weight: 700; }
.account-summary h2, .auth-heading h2 { margin: 0 0 7px; font-size: 25px; }
.account-summary p, .auth-heading p { margin: 0; color: var(--ink-soft); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 13px; }
.account-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding-top: 26px; }
.text-button { padding: 0; border: 0; background: transparent; color: var(--teal); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 13px; font-weight: 700; }
.text-button:hover { color: var(--orange-dark); }
.auth-heading { margin-bottom: 26px; }
.auth-form, .admin-form { display: grid; gap: 17px; }
.auth-form label, .admin-form label, .comment-form label { display: grid; gap: 7px; color: var(--ink); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 13px; font-weight: 700; }
.auth-form input, .admin-form input, .admin-form select, .auth-form textarea, .admin-form textarea, .comment-form textarea { width: 100%; border: 1px solid var(--line); border-radius: 2px; padding: 11px 12px; background: var(--paper); color: var(--ink); font: inherit; font-size: 14px; outline: none; }
.auth-form input:focus, .admin-form input:focus, .admin-form select:focus, .admin-form textarea:focus, .comment-form textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(24,93,88,.12); }
.auth-form button, .admin-form > button, .comment-form button { justify-self: start; border: 0; border-radius: 2px; padding: 11px 21px; background: var(--orange); color: white; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 14px; font-weight: 700; }
.auth-form button:disabled, .comment-form button:disabled { opacity: .6; cursor: wait; }
.account-card > .text-button { margin-top: 19px; }
.form-message { min-height: 1.2em; margin: -5px 0 0; color: var(--orange-dark); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 12px; line-height: 1.5; }

.comments-section { max-width: 860px; margin: 0 auto 100px; }
.comment-list { display: grid; gap: 0; border-top: 1px solid var(--line); }
.comment { padding: 20px 2px; border-bottom: 1px solid var(--line); }
.comment div { display: flex; align-items: center; gap: 12px; }
.comment b { font-family: ui-sans-serif, system-ui, sans-serif; font-size: 13px; }
.comment time { color: var(--ink-soft); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 11px; }
.comment p { margin: 10px 0 0; color: var(--ink-soft); font-size: 15px; line-height: 1.75; white-space: pre-wrap; }
.comment-login { margin: 24px 0 0; color: var(--ink-soft); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 13px; }
.comment-login a { color: var(--teal); font-weight: 700; }
.comment-form { margin-top: 28px; padding: 24px; background: var(--paper-deep); }
.comment-form textarea { min-height: 110px; resize: vertical; }
.comment-form > div { display: flex; align-items: center; justify-content: space-between; gap: 15px; }

.admin-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 27px; margin: 52px 0 100px; }
.admin-card { padding: clamp(24px, 4vw, 38px); background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); }
.admin-card h2 { margin: 0 0 26px; font-size: 27px; }
.form-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.admin-form textarea { min-height: 112px; resize: vertical; line-height: 1.65; }
.admin-form .chapter-content { min-height: 300px; font-family: ui-serif, Georgia, serif; line-height: 1.8; }
.check-row { display: flex; flex-wrap: wrap; gap: 20px; }
.check-row label { display: flex; align-items: center; gap: 7px; color: var(--ink-soft); font-size: 13px; font-weight: 500; }
.check-row input { width: auto; accent-color: var(--teal); }

@media (max-width: 760px) {
  .account-area { margin-left: auto; }
  .account-link, .admin-link { font-size: 12px; }
  .admin-link { display: none; }
  .admin-layout { grid-template-columns: 1fr; margin-top: 36px; }
  .form-columns { grid-template-columns: 1fr; }
  .comment-form { padding: 19px; }
}
