:root {
  --library-ink: #123f31;
  --library-green: #087c45;
  --library-muted: #607568;
  --library-line: #d5e1ce;
  --library-soft: #edf4e5;
  --library-cream: #fbfaf3;
}

.book-icon,.detail-cover-content { position: relative; overflow: hidden; }
.book-icon img,.detail-cover-content img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #edf4e5; }
.catalog-detail-page { max-width: 1040px; margin: auto; padding: 32px 20px 64px; }
.catalog-back { display: inline-block; margin-bottom: 24px; color: #50745b; }
.catalog-detail-page .book-detail-shell { background: white; border: 1px solid #d5e1ce; border-radius: 24px; }
.detail-cover-content { display: grid; place-items: center; width: 100%; height: 100%; }
.book-detail-heading h1 { font-size: clamp(26px,4vw,42px); line-height: 1.35; }
.book-detail-copy h2,.book-detail-recommendation h2 { font-size: 21px; margin-bottom: 12px; }
main { overflow: hidden; background: var(--library-cream); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.library-hero {
  min-height: 400px;
  padding: 54px max(clamp(20px, 4vw, 64px), calc((100% - 1360px) / 2));
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, .68fr);
  align-items: center;
  gap: clamp(44px, 8vw, 120px);
  border-bottom: 1px solid var(--library-line);
  background: radial-gradient(circle at 78% 46%, rgba(190,220,157,.3), transparent 28%), linear-gradient(140deg,#fbfaf3 0%,#f7f9f0 68%,#edf5e7 100%);
}
.library-eyebrow { margin: 0 0 18px; color: #617d6b; font-size: 12px; font-weight: 700; letter-spacing: .2em; }
.library-hero h1 { margin: 0; color: var(--library-ink); font-size: clamp(46px,5vw,74px); line-height: 1.18; letter-spacing: -.045em; }
.library-hero-copy > p:last-child { max-width: 690px; margin: 28px 0 0; color: var(--library-muted); font-size: clamp(16px,1.3vw,20px); line-height: 1.85; }
.library-mark { position: relative; min-height: 280px; display: grid; place-items: center; border: 1px solid var(--library-line); border-radius: 36px; background: rgba(255,255,255,.68); box-shadow: 0 20px 52px rgba(34,74,47,.07); }
.mark-ring { position: absolute; width: 210px; height: 210px; border: 1px dashed rgba(8,124,69,.22); border-radius: 50%; }
.library-mark img { position: relative; z-index: 1; display: block; width: min(82%,320px); height: auto; }

.book-section { padding: 60px max(clamp(20px, 4vw, 64px), calc((100% - 1360px) / 2)) 88px; background: linear-gradient(180deg,#f5f8f1,#f0f5eb); }
.book-section-heading { margin-bottom: 28px; }
.book-title-search { display: flex; align-items: center; gap: clamp(24px, 4vw, 64px); }
.book-title-search h2 { flex: 0 0 auto; }
.book-title-search .book-search { flex: 1; max-width: 780px; min-width: 0; padding-left: 20px; min-height: 56px; }
.catalog-browse-bar { display: flex; align-items: flex-start; gap: 20px; padding: 16px; border: 1px solid #e0e8d9; border-radius: 16px; background: rgba(255,255,255,.7); }
.book-theme-tabs { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.book-theme-tab { border: 0; padding: 8px 12px; border-radius: 9px; background: transparent; color: #687d6f; cursor: pointer; font-size: 13px; line-height: 22px; }
.book-theme-tab:hover { color: var(--library-green); }
.book-theme-tab[aria-pressed="true"] { color: #fff; background: var(--library-green); font-weight: 700; }
.book-grade-control { display: flex; flex: 0 0 auto; align-items: center; gap: 10px; color: var(--library-muted); font-size: 13px; }
.book-grade-control select { min-height: 40px; max-width: 160px; padding: 0 12px; border: 1px solid var(--library-line); border-radius: 10px; color: var(--library-ink); background: #fff; font: inherit; }
.book-results-row { display: flex; align-items: center; gap: 16px; min-height: 60px; padding: 12px 0; color: var(--library-muted); font-size: 13px; }
.book-results-row .book-reset { min-height: 32px; padding: 0 12px; font-size: 12px; }
.book-section-heading .library-eyebrow { margin-bottom: 12px; }
.book-section-heading h2 { margin: 0; color: var(--library-ink); font-size: clamp(34px,3vw,50px); letter-spacing: -.04em; }
.book-section-intro { margin: 12px 0 0; color: var(--library-muted); line-height: 1.7; }
.book-search-wrap { width: min(540px,48%); display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 9px; }
.book-search { position: relative; min-height: 52px; padding: 5px 5px 5px 46px; display: flex; align-items: center; gap: 8px; border: 1px solid #cbdac4; border-radius: 15px; background: rgba(255,255,255,.9); }
.book-search:focus-within { border-color: var(--library-green); box-shadow: 0 0 0 3px rgba(8,124,69,.08); }
.book-search svg { position: absolute; left: 16px; width: 19px; height: 19px; color: #66806f; fill: none; stroke: currentColor; stroke-width: 1.8; }
.book-search input { flex: 1; min-width: 0; min-height: 40px; padding: 0; border: 0; outline: 0; color: #294438; background: transparent; font: inherit; font-size: 14px; }
.book-search input::placeholder { color: #8b9b90; }
.book-search select { flex-shrink: 0; max-width: 110px; border: 0; border-left: 1px solid #dce6d6; padding: 8px; color: #55715e; background: transparent; font: inherit; font-size: 13px; }
.book-search #book-search-clear { padding: 0 6px; min-height: 32px; background: transparent; color: #7b8a7e; font-size: 22px; }
.book-search button:disabled { opacity: .6; cursor: wait; }
#book-ai-grid { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 22px; margin-top: 4px; }
.ai-book-card { display: flex; flex-direction: column; gap: 18px; min-width: 0; padding: 24px; border: 1px solid #dce6d4; border-radius: 22px; background: #fff; box-shadow: 0 6px 22px rgba(34,74,47,.035); }
.ai-book-header { min-width: 0; padding-bottom: 16px; border-bottom: 1px solid #edf1e8; }
.ai-book-source { display: inline-block; max-width: 100%; box-sizing: border-box; margin-bottom: 12px; padding: 4px 9px; border-radius: 7px; color: #36724d; background: #edf5e7; font-size: 11px; line-height: 1.6; overflow-wrap: anywhere; }
.ai-book-source.is-external { color: #7b663f; background: #f7f1e4; }
.ai-book-card h3 { margin: 0; color: var(--library-ink); font-size: 22px; line-height: 1.45; overflow-wrap: anywhere; }
.ai-book-card .ai-book-author { margin: 7px 0 0; color: #758377; font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.ai-book-label { margin: 0 0 7px; color: #3d674e; font-size: 12px; line-height: 1.6; font-weight: 700; }
.ai-book-text { margin: 0; color: #52695b; font-size: 14px; line-height: 1.85; overflow-wrap: anywhere; white-space: pre-line; }
.ai-book-grade { padding-left: 12px; border-left: 3px solid #d9e6ca; }
.ai-book-question { padding: 14px 16px; border: 1px solid #e9ecde; border-radius: 12px; background: #f8faf3; }
.ai-book-question .ai-book-label { color: #718052; }
.ai-book-card .ai-book-action { display: flex; align-items: center; justify-content: center; min-height: 44px; margin-top: auto; padding: 8px 12px; border: 1px solid #dce8d1; border-radius: 11px; background: #edf5e7; color: #236842; font-size: 14px; line-height: 1.6; font-weight: 700; text-align: center; text-decoration: none; }
.ai-book-action:hover { background: #e1eed8; }
.ai-book-action:focus-visible { outline: 3px solid #87b17b; outline-offset: 3px; }
.ai-book-card .ai-book-action.is-external { background: #f8f6ef; color: #746242; border-color: #e9e3d5; }
@media (max-width: 1100px) { #book-ai-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media (max-width: 760px) { #book-ai-grid { grid-template-columns: minmax(0,1fr); gap: 16px; } .ai-book-card { gap: 16px; padding: 20px; } .ai-book-card h3 { font-size: 21px; } }
.book-ai-guide { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; margin-bottom: 20px; border: 1px solid #d7e5cb; border-radius: 14px; background: #f9fcf5; }
.book-ai-guide div { min-width: 0; overflow-wrap: anywhere; }
.book-ai-guide strong { color: var(--library-ink); font-size: 14px; }
.book-ai-guide p,.book-ai-scope { margin: 6px 0 0; font-size: 12px; line-height: 1.7; color: var(--library-muted); }
.book-ai-guide button { flex-shrink: 0; }
.book-ai-section { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--library-line); }
.book-ai-section > h3 { color: var(--library-ink); font-size: 24px; margin: 0; }
#book-ai-status.is-loading { display: flex; align-items: center; gap: 12px; width: 100%; box-sizing: border-box; margin: 8px 0; padding: 18px 20px; border: 1px solid #d9e7d0; border-radius: 14px; background: #f9fcf5; color: #316744; line-height: 1.8; }
#book-ai-status.is-loading::before { content: ''; flex: none; width: 20px; height: 20px; box-sizing: border-box; border: 2px solid #dce9d4; border-top-color: #087c45; border-right-color: #087c45; border-radius: 50%; animation: book-ai-spin .9s linear infinite; }
#book-search-submit[aria-busy="true"] { opacity: 1; cursor: progress; }
@keyframes book-ai-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #book-ai-status.is-loading::before { animation: none; } }
@media (max-width: 480px) { .book-ai-guide { align-items: stretch; flex-direction: column; padding: 16px; } }
.book-search button,.book-reset { min-height: 40px; padding: 0 17px; border-radius: 11px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 700; }
.book-search button { border: 0; color: #fff; background: var(--library-green); }
.book-search button:hover { background: #066934; }
.book-reset { border: 1px solid #b9ceb2; color: #3f6a4d; background: #f6f9f1; }
.book-search-status { min-height: 18px; margin: 0; grid-column: 1 / -1; color: #667b6d; font-size: 12px; line-height: 1.5; text-align: right; }

.book-filters { width: fit-content; margin: 0 0 32px; padding: 12px 14px; display: flex; gap: 14px; border: 1px solid var(--library-line); border-radius: 16px; background: rgba(255,255,255,.78); box-shadow: 0 8px 24px rgba(34,74,47,.04); }
.book-filters label { display: flex; align-items: center; gap: 10px; color: #526b5c; font-size: 13px; font-weight: 650; }
.book-filters select { min-height: 40px; padding: 0 38px 0 14px; border: 1px solid #c8d9c0; border-radius: 11px; color: #294438; background: #fff; font: inherit; cursor: pointer; }

.book-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: clamp(18px,1.8vw,28px); }
.book-card { position: relative; min-height: 244px; padding: 18px; display: flex; flex-direction: column; align-items: stretch; gap: 16px; overflow: hidden; border: 1px solid #dce6d4; border-radius: 20px; background: #fff; box-shadow: 0 4px 18px rgba(38,76,48,.035); transition: border-color .2s ease,box-shadow .2s ease; }
.book-card:hover { border-color: #aac79b; box-shadow: 0 10px 28px rgba(34,74,47,.08); }
.book-card-link { flex: 1; min-width: 0; min-height: 150px; display: grid; grid-template-columns: minmax(80px,32%) minmax(0,1fr); gap: 16px; align-items: center; }
.book-card-link:focus-visible,.book-card-actions button:focus-visible { outline: 3px solid rgba(8,124,69,.28); outline-offset: 3px; }
.book-card-actions { display: grid; grid-template-columns: minmax(0,1.4fr) repeat(2,minmax(0,1fr)); gap: 6px; padding-top: 14px; border-top: 1px solid #edf1e8; }
.book-card-actions button { min-width: 0; min-height: 42px; padding: 8px 4px; display: flex; align-items: center; justify-content: center; gap: 4px; border-radius: 9px; font: inherit; font-size: 12px; font-weight: 650; line-height: 1.5; white-space: nowrap; }
.book-card-actions svg { width: 15px; height: 15px; flex: 0 0 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.book-card .book-action-status { position: absolute; z-index: 1; left: 18px; right: 18px; bottom: 76px; margin: 0; padding: 7px 10px; border: 1px solid #dce6d4; border-radius: 9px; color: #236542; background: #f6faf2; box-shadow: 0 4px 14px rgba(34,74,47,.08); pointer-events: none; }
.book-card-actions .book-purchase:hover { background: #e0eedc; }
.book-icon { width: 100%; aspect-ratio: 3/4; display: grid; place-items: center; border-radius: 10px; color: rgba(18,63,49,.22); background: linear-gradient(145deg,#edf5e2,#dcebc9); box-shadow: inset 0 0 0 1px rgba(255,255,255,.45); font-family: "STSong","SimSun",serif; font-size: clamp(42px,3.4vw,60px); font-weight: 700; }
.book-card-content { min-width: 0; }
.book-card h3 { margin: 0; display: -webkit-box; overflow: hidden; color: var(--library-ink); font-size: clamp(18px,1.25vw,22px); line-height: 1.5; letter-spacing: -.02em; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.book-author,.book-grade { margin: 9px 0 0; overflow: hidden; color: #65796c; font-size: 13px; line-height: 1.5; text-overflow: ellipsis; white-space: nowrap; }
.book-grade { color: #789080; }
.book-theme { margin-top: 12px; padding: 5px 9px; display: inline-block; border-radius: 8px; color: #53715d; background: var(--library-soft); font-size: 11px; font-weight: 700; }
.book-number { position: absolute; right: 15px; bottom: 13px; color: #8ca091; font-size: 10px; font-weight: 700; letter-spacing: .12em; }
.book-empty { margin: 20px 0; padding: 50px 20px; border: 1px dashed #b8ccb0; border-radius: 18px; color: var(--library-muted); text-align: center; }
.book-catalog-note { margin-top: 48px; padding: 20px 24px; display: flex; gap: 20px; align-items: baseline; border: 1px solid #d5e2cc; border-radius: 18px; color: #607568; background: rgba(255,255,255,.58); }
.book-catalog-note strong { flex: 0 0 auto; color: var(--library-ink); }
.book-catalog-note p { margin: 0; line-height: 1.75; }

.book-detail-dialog { width: min(820px,calc(100% - 32px)); max-height: calc(100dvh - 32px); padding: 0; overflow: auto; border: 0; border-radius: 28px; color: var(--library-ink); background: #fff; box-shadow: 0 28px 80px rgba(18,63,49,.24); }
.book-detail-dialog::backdrop { background: rgba(12,37,28,.58); backdrop-filter: blur(4px); }
.book-detail-shell { position: relative; padding: clamp(26px,5vw,48px); }
.book-detail-close { position: absolute; z-index: 2; top: 18px; right: 18px; width: 42px; height: 42px; border: 0; border-radius: 50%; color: #456356; background: #eff5eb; cursor: pointer; font-size: 28px; line-height: 1; }
.book-detail-hero { display: grid; grid-template-columns: 180px minmax(0,1fr); gap: 34px; align-items: center; }
.book-detail-cover { aspect-ratio: 3/4; display: grid; place-items: center; border-radius: 20px; color: rgba(18,63,49,.25); background: linear-gradient(145deg,#edf5e2,#dcebc9); font-family: "STSong","SimSun",serif; font-size: 72px; font-weight: 700; }
.book-detail-kicker { margin: 0 0 10px; color: #789080; font-size: 12px; font-weight: 750; letter-spacing: .12em; }
.book-detail-heading h2 { margin: 0; font-size: clamp(30px,4vw,46px); line-height: 1.25; letter-spacing: -.04em; }
.book-detail-heading > p:not(.book-detail-kicker) { margin: 12px 0 0; color: #647a6c; font-size: 18px; }
.book-detail-tags { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 9px; }
.book-detail-tags span { padding: 7px 11px; border-radius: 9px; color: #55715e; background: var(--library-soft); font-size: 13px; }
.book-detail-meta { margin: 30px 0; padding: 0 20px; border: 1px solid #dce6d6; border-radius: 18px; background: #f9fbf6; }
.book-detail-meta div { padding: 15px 0; display: flex; justify-content: space-between; gap: 20px; border-bottom: 1px solid #e5ece0; }
.book-detail-meta div:last-child { border-bottom: 0; }
.book-detail-meta dt { color: #7a8e81; }
.book-detail-meta dd { margin: 0; color: #345444; text-align: right; }
.book-detail-copy h3,.book-detail-recommendation h3 { margin: 0 0 10px; font-size: 22px; }
.book-detail-copy p,.book-detail-recommendation p,.book-detail-rights p { margin: 0; color: #526d5d; line-height: 1.85; }
.book-detail-recommendation { margin-top: 24px; padding: 22px 24px; border-radius: 18px; background: #f0f6e9; }
.book-detail-rights { margin-top: 20px; padding: 17px 20px; border-left: 4px solid #8bb57d; border-radius: 4px 14px 14px 4px; background: #f7f9f4; }
.book-detail-rights strong { display: block; margin-bottom: 5px; }
.book-purchase { border: 1px solid #bed2b6; color: #236542; background: #edf5ed; cursor: pointer; }
.book-reading-disabled { border: 1px solid #d8e2d3; color: #81947e; background: #eef2e9; cursor: not-allowed; }
.book-action-status { min-height: 22px; margin: 10px 0 0; color: #5d7668; font-size: 13px; text-align: center; }

@media (max-width: 1280px) {
  .library-hero { min-height: 400px; grid-template-columns: 1fr 300px; }
  .book-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (max-width: 960px) {
  .book-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 760px) {
  .library-hero { min-height: auto; padding: 58px 22px; grid-template-columns: 1fr; gap: 34px; }
  .library-hero h1 { font-size: clamp(38px,11vw,54px); }
  .library-mark { min-height: 250px; }
  .mark-ring { width: 190px; height: 190px; }
  .book-section { padding: 64px 20px 80px; }
  .book-title-search { flex-direction: column; align-items: stretch; gap: 18px; }
  .book-title-search .book-search { width: 100%; max-width: none; flex: auto; }
  .catalog-browse-bar { flex-direction: column; gap: 12px; }
  .book-theme-tabs { width: 100%; gap: 5px; }
  .book-theme-tab { padding: 7px 10px; font-size: 13px; }
  .book-grade-control { align-self: flex-end; }
  .book-search-wrap { width: 100%; }
  .book-filters { width: 100%; align-items: stretch; flex-direction: column; }
  .book-filters label { justify-content: space-between; }
  .book-filters select { width: min(65%,260px); }
  .book-grid { grid-template-columns: 1fr; gap: 18px; }
  .book-card { min-height: 222px; padding: 18px; }
  .book-card-link { min-height: 140px; grid-template-columns: 96px minmax(0,1fr); }
  .book-icon { font-size: 48px; }
  .book-card h3 { font-size: 21px; }
  .book-catalog-note { align-items: flex-start; flex-direction: column; gap: 8px; }
  .book-detail-dialog { width: calc(100% - 20px); max-height: calc(100dvh - 20px); border-radius: 22px; }
  .book-detail-hero { grid-template-columns: 110px minmax(0,1fr); gap: 20px; align-items: start; }
  .book-detail-cover { border-radius: 14px; font-size: 48px; }
  .book-detail-heading h2 { padding-right: 32px; font-size: 28px; }
  .book-detail-heading > p:not(.book-detail-kicker) { font-size: 15px; }
}
@media (max-width: 380px) {
  .book-search-wrap { grid-template-columns: 1fr; }
  .book-search { padding-left: 42px; }
  .book-reset { justify-self: end; }
  .book-card { gap: 15px; }
  .book-card-link { grid-template-columns: 96px minmax(0,1fr); gap: 15px; }
  .book-icon { font-size: 44px; }
  .book-card h3 { font-size: 20px; }
  .book-author,.book-grade { font-size: 12px; }
  .book-detail-hero { grid-template-columns: 82px minmax(0,1fr); }
  .book-detail-heading h2 { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) { .book-card { transition: none; } }
