/* ============================================================
   도서관(영어도서관 / 러시아어도서관) — 2026-11-22. 비즈영어·루스키 공용 파일.
   표지 중심: 글자보다 그림이 먼저 보이게. 모바일 우선, 1024 / 768 / 480 대응.
   포인트 색은 --lib-accent (비즈영어 기본 레드, 루스키는 index.html에서 블루로 지정)
   ============================================================ */
#libraryPage { --lib-accent: #b91c1c; --lib-ink: #1c1917; --lib-sub: #78716c; --lib-line: #e7e5e4; --lib-paper: #fffdf8; background: #faf8f3; }
#libraryPage.lib-reading { background: #f3efe6; }
.lib-wrap { max-width: 1120px; margin: 0 auto; padding: 108px 20px 64px; color: var(--lib-ink); }
.lib-reading .lib-wrap { max-width: 980px; padding: 96px 16px 24px; }

.lib-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.lib-title { font-size: 28px; font-weight: 800; margin: 0 0 6px; letter-spacing: -0.02em; text-wrap: balance; }
.lib-title span { font-size: 14px; font-weight: 600; color: var(--lib-sub); margin-left: 8px; letter-spacing: 0.04em; }
.lib-desc { margin: 0; font-size: 14.5px; color: var(--lib-sub); line-height: 1.6; max-width: 60ch; }
.lib-streak { flex: none; font-size: 13px; color: var(--lib-sub); padding: 8px 14px; border: 1px solid var(--lib-line); border-radius: 999px; background: #fff; }
.lib-streak b { font-size: 17px; color: var(--lib-accent); margin-right: 3px; font-variant-numeric: tabular-nums; }

.lib-notice { font-size: 13.5px; line-height: 1.6; color: #57534e; background: #fff; border: 1px solid var(--lib-line); border-left: 3px solid var(--lib-accent); padding: 10px 14px; margin-bottom: 14px; }
.lib-notice-admin { border-left-color: #a16207; background: #fefce8; color: #713f12; }

.lib-tabs { display: flex; gap: 6px; overflow-x: auto; margin: 22px 0 8px; border-bottom: 1px solid var(--lib-line); scrollbar-width: none; }
.lib-tabs::-webkit-scrollbar { display: none; }
.lib-tab { flex: none; appearance: none; background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 16px 11px; font: inherit; font-size: 16px; font-weight: 700; color: var(--lib-sub); cursor: pointer; text-align: left; min-height: 48px; }
.lib-tab small { display: block; font-size: 11.5px; font-weight: 500; color: #a8a29e; margin-top: 2px; }
.lib-tab:hover { color: var(--lib-ink); }
.lib-tab.active { color: var(--lib-ink); border-bottom-color: var(--lib-accent); }
.lib-div-meta { font-size: 12.5px; color: #a8a29e; margin-bottom: 6px; }

/* 서가 = 책이 올라가 있는 선반 한 줄 */
.lib-shelf { margin-top: 22px; }
.lib-shelf-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.lib-shelf-head h3 { font-size: 18px; font-weight: 800; margin: 0; }
.lib-shelf-head a { font-size: 13px; color: var(--lib-sub); text-decoration: none; white-space: nowrap; }
.lib-shelf-head a:hover { color: var(--lib-accent); }
.lib-row { display: flex; gap: 18px; overflow-x: auto; padding: 6px 4px 14px; align-items: flex-end; border-bottom: 6px solid #e2d9c8; box-shadow: 0 7px 8px -8px rgba(68, 51, 22, 0.35); scroll-snap-type: x proximity; }
.lib-row .lib-card { flex: none; width: 138px; scroll-snap-align: start; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); gap: 24px 18px; margin-top: 16px; }

.lib-card { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: inherit; min-width: 0; }
.lib-cover { position: relative; display: block; aspect-ratio: 3 / 4; background: #ece7dc; border-radius: 3px 6px 6px 3px; overflow: hidden; box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06), 2px 4px 10px rgba(68, 51, 22, 0.22); transition: transform 0.18s ease, box-shadow 0.18s ease; }
.lib-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-cover-none { display: flex; align-items: center; justify-content: center; height: 100%; padding: 12px; font-size: 14px; font-weight: 700; text-align: center; line-height: 1.35; color: #57534e; background: linear-gradient(160deg, #f1ebdd, #e3dac6); overflow-wrap: anywhere; }
.lib-card:hover .lib-cover, .lib-card:focus-visible .lib-cover { transform: translateY(-4px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06), 4px 10px 18px rgba(68, 51, 22, 0.28); }
.lib-card:focus-visible { outline: 2px solid var(--lib-accent); outline-offset: 4px; border-radius: 4px; }
.lib-lock, .lib-done { position: absolute; left: 6px; bottom: 6px; font-size: 11px; font-weight: 700; padding: 3px 7px; border-radius: 3px; background: rgba(28, 25, 23, 0.78); color: #fff; }
.lib-done { left: auto; right: 6px; background: var(--lib-accent); }
.lib-card-title { font-size: 14px; font-weight: 700; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.lib-card-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--lib-sub); }
.lib-lv { font-size: 11px; font-weight: 800; padding: 2px 6px; border-radius: 3px; color: #fff; background: #57534e; font-variant-numeric: tabular-nums; }
.lib-lv-1 { background: #15803d; } .lib-lv-2 { background: #0f766e; } .lib-lv-3 { background: #1d4ed8; } .lib-lv-4 { background: #6d28d9; }

.lib-empty { padding: 44px 16px; text-align: center; font-size: 14.5px; color: var(--lib-sub); line-height: 1.7; }
.lib-pando:empty { display: none; }   /* 안내 캐릭터 판도 자리 — 이미지 파일을 받으면 채운다 */
.lib-waiting { margin-top: 26px; font-size: 13px; color: #a8a29e; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.lib-waiting span { border: 1px dashed #d6d3d1; padding: 3px 9px; border-radius: 3px; color: var(--lib-sub); }
.lib-foot { margin-top: 44px; padding-top: 14px; border-top: 1px solid var(--lib-line); font-size: 13px; }
.lib-foot a, .lib-back { color: var(--lib-sub); text-decoration: none; }
.lib-foot a:hover, .lib-back:hover { color: var(--lib-accent); }
.lib-back { display: inline-block; font-size: 14px; margin-bottom: 14px; padding: 6px 0; }
.lib-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.lib-chip { appearance: none; font: inherit; font-size: 13px; padding: 7px 12px; border: 1px solid var(--lib-line); background: #fff; color: #57534e; border-radius: 3px; cursor: pointer; min-height: 36px; }
.lib-chip.active { background: var(--lib-ink); border-color: var(--lib-ink); color: #fff; }

.lib-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 20px; border: 1px solid #d6d3d1; background: #fff; color: var(--lib-ink); font-size: 15px; font-weight: 700; border-radius: 4px; text-decoration: none; cursor: pointer; }
.lib-btn:hover { border-color: var(--lib-ink); }
.lib-btn-main { background: var(--lib-accent); border-color: var(--lib-accent); color: #fff; }
.lib-btn-main:hover { filter: brightness(0.93); border-color: var(--lib-accent); }

/* 책 상세 */
.lib-detail { display: grid; grid-template-columns: 260px 1fr; gap: 36px; align-items: start; }
.lib-detail-cover { aspect-ratio: 3 / 4; background: #ece7dc; border-radius: 3px 8px 8px 3px; overflow: hidden; box-shadow: 4px 10px 24px rgba(68, 51, 22, 0.26); }
.lib-detail-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-detail-where { font-size: 12.5px; color: var(--lib-sub); letter-spacing: 0.02em; }
.lib-detail-title { font-size: 30px; font-weight: 800; line-height: 1.2; margin: 6px 0 4px; letter-spacing: -0.02em; text-wrap: balance; overflow-wrap: anywhere; }
.lib-detail-ko { font-size: 16px; color: #57534e; }
.lib-detail-by { font-size: 13.5px; color: var(--lib-sub); margin-top: 6px; }
.lib-facts { display: grid; grid-template-columns: repeat(4, auto); justify-content: start; gap: 0 28px; margin: 20px 0; padding: 14px 0; border-top: 1px solid var(--lib-line); border-bottom: 1px solid var(--lib-line); }
.lib-facts dt { font-size: 11.5px; color: #a8a29e; margin-bottom: 3px; }
.lib-facts dd { margin: 0; font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.lib-facts small { font-size: 12px; font-weight: 500; color: var(--lib-sub); }
.lib-detail-sum { font-size: 15px; line-height: 1.75; color: #44403c; margin: 0 0 16px; max-width: 62ch; }
.lib-keys { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 22px; }
.lib-keys span { font-size: 12px; color: #a8a29e; margin-right: 4px; }
.lib-keys b { font-size: 14px; font-weight: 600; padding: 4px 10px; background: #fff; border: 1px solid var(--lib-line); border-radius: 3px; }
.lib-eps { margin-top: 32px; }
.lib-eps h3 { font-size: 16px; margin: 0 0 8px; }
.lib-ep { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center; padding: 13px 4px; border-top: 1px solid var(--lib-line); text-decoration: none; color: inherit; min-height: 48px; }
.lib-ep:hover b { color: var(--lib-accent); }
.lib-ep small { color: var(--lib-sub); font-size: 12.5px; }
.lib-ep.is-done { color: #a8a29e; }

/* 리더 — 한 화면 = 그림 1장 + 글 */
.lib-reader { display: flex; flex-direction: column; background: var(--lib-paper); border: 1px solid #e2d9c8; border-radius: 8px; box-shadow: 0 10px 30px rgba(68, 51, 22, 0.12); height: calc(100vh - 124px); height: calc(100dvh - 124px); min-height: 460px; overflow: hidden; }
.lib-rd-top { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid #efe9db; }
.lib-rd-x { flex: none; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; font-size: 20px; color: #57534e; text-decoration: none; border-radius: 6px; }
.lib-rd-x:hover { background: #f3efe6; }
.lib-rd-name { flex: 1; min-width: 0; font-size: 14.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-rd-name small { font-weight: 500; color: var(--lib-sub); margin-left: 6px; }
.lib-rd-count { flex: none; font-size: 13px; color: var(--lib-sub); font-variant-numeric: tabular-nums; padding-right: 6px; }
.lib-rd-bar { height: 3px; background: #efe9db; }
.lib-rd-bar i { display: block; height: 100%; background: var(--lib-accent); transition: width 0.25s ease; }

.lib-rd-stage { position: relative; flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; align-items: center; padding: 18px 28px 22px; gap: 18px; -webkit-overflow-scrolling: touch; }
.lib-rd-img { flex: 1 1 55%; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
.lib-rd-img img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; }
.lay-image_full .lib-rd-img { flex-basis: 72%; }
.lib-rd-text { flex: 0 0 auto; width: 100%; max-width: 34em; font-family: Georgia, 'Iowan Old Style', 'Times New Roman', 'Noto Serif KR', serif; font-size: 23px; line-height: 1.7; color: #1c1917; }
.lib-rd-text p { margin: 0 0 0.55em; }
.lib-rd-text p:last-child { margin-bottom: 0; }
.lay-text_only { justify-content: center; }
.lay-text_only .lib-rd-text { margin: auto 0; }
/* 유치부·초등은 큰 글씨와 넉넉한 줄 간격 */
.div-kinder .lib-rd-text { font-size: 31px; line-height: 1.75; text-align: center; font-family: 'Trebuchet MS', 'Segoe UI', 'Noto Sans KR', sans-serif; }
.div-elem-lower .lib-rd-text { font-size: 27px; font-family: 'Trebuchet MS', 'Segoe UI', 'Noto Sans KR', sans-serif; }
.div-elem-upper .lib-rd-text { font-size: 24px; }
.is-article .lib-rd-text { font-size: 19.5px; max-width: 40em; }
.lib-w { cursor: pointer; border-radius: 4px; padding: 1px 1px; margin: 0 -1px; transition: background 0.12s ease; }
.lib-w:hover { background: #f1ead9; }
.lib-w.on { background: #fde68a; box-shadow: 0 0 0 2px #fde68a; }
.lib-rd-trans { margin-top: 14px; padding-top: 12px; border-top: 1px dashed #d6d3d1; font-family: 'Noto Sans KR', 'Malgun Gothic', sans-serif; font-size: 15px; line-height: 1.7; color: #57534e; }

.lib-rd-ctrl { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-top: 1px solid #efe9db; background: #fff; }
.lib-rd-nav { appearance: none; width: 56px; height: 52px; border: 1px solid #d6d3d1; background: #fff; border-radius: 8px; font-size: 30px; line-height: 1; color: var(--lib-ink); cursor: pointer; }
.lib-rd-nav:hover:not(:disabled) { border-color: var(--lib-ink); }
.lib-rd-nav:disabled { opacity: 0.3; cursor: default; }
#libRdNext:not(:disabled) { background: var(--lib-ink); border-color: var(--lib-ink); color: #fff; }
.lib-rd-tools { display: flex; gap: 8px; align-items: center; }
.lib-rd-play, .lib-rd-rate, .lib-rd-ko { appearance: none; font: inherit; min-height: 46px; padding: 0 16px; border: 1px solid #d6d3d1; background: #fff; border-radius: 8px; font-size: 14.5px; font-weight: 700; color: var(--lib-ink); cursor: pointer; }
.lib-rd-play { min-width: 84px; background: var(--lib-accent); border-color: var(--lib-accent); color: #fff; }
.lib-rd-play.active { background: #fff; color: var(--lib-accent); }
.lib-rd-play:disabled { opacity: 0.35; cursor: default; }
.lib-rd-rate { font-variant-numeric: tabular-nums; min-width: 64px; }
.lib-rd-ko.active { background: var(--lib-ink); border-color: var(--lib-ink); color: #fff; }
.lib-rd-ko.hidden { display: none; }
.lib-rd-nav:focus-visible, .lib-rd-play:focus-visible, .lib-rd-rate:focus-visible, .lib-rd-ko:focus-visible, .lib-btn:focus-visible, .lib-tab:focus-visible, .lib-chip:focus-visible { outline: 2px solid var(--lib-accent); outline-offset: 2px; }

/* 단어 팝업 */
.lib-pop { position: absolute; z-index: 5; min-width: 180px; max-width: 280px; background: #1c1917; color: #fff; border-radius: 8px; padding: 12px 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28); font-family: 'Noto Sans KR', 'Malgun Gothic', sans-serif; }
.lib-pop-word { font-size: 18px; font-weight: 800; }
.lib-pop-word small { font-size: 12.5px; font-weight: 500; color: #d6d3d1; margin-left: 4px; }
.lib-pop-mean { font-size: 14px; line-height: 1.5; color: #f5f5f4; margin-top: 4px; }
.lib-pop-mean i { color: #a8a29e; font-size: 12px; }
.lib-pop-mean small { display: block; color: #a8a29e; font-size: 12px; margin-top: 2px; }
.lib-pop-act { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.lib-pop-act button { appearance: none; font: inherit; font-size: 13px; font-weight: 700; min-height: 36px; padding: 0 12px; border-radius: 6px; border: 1px solid #57534e; background: transparent; color: #fff; cursor: pointer; }
.lib-pop-act button:hover { background: #292524; }
.lib-pop-act button.done { border-color: #15803d; color: #86efac; }

/* 마지막 장: 다 읽음 + 크레딧 */
.lib-rd-stage.is-credits { justify-content: flex-start; }
.lib-credits { width: 100%; max-width: 620px; margin: 0 auto; padding: 12px 0; }
.lib-credits h3 { font-size: 22px; font-weight: 800; margin: 8px 0 14px; text-align: center; }
.lib-credits-act { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 26px; }
.lib-credits-list { margin: 0; border-top: 1px solid var(--lib-line); }
.lib-credits-list > div { display: grid; grid-template-columns: 84px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--lib-line); font-size: 13.5px; line-height: 1.6; }
.lib-credits-list dt { color: #a8a29e; }
.lib-credits-list dd { margin: 0; color: #44403c; overflow-wrap: anywhere; }
.lib-credits-list a { color: var(--lib-accent); }

/* 출처와 라이선스 */
.lib-src { margin-top: 26px; }
.lib-src h3 { font-size: 16px; margin: 0 0 6px; }
.lib-src ul { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--lib-line); }
.lib-src li { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--lib-line); font-size: 14px; }
.lib-src li span { color: var(--lib-sub); font-size: 13px; }
.lib-src li a { color: var(--lib-accent); font-size: 13px; text-decoration: none; overflow-wrap: anywhere; }
.lib-src li em { flex-basis: 100%; font-style: normal; font-size: 12.5px; color: var(--lib-sub); }

@media (max-width: 1024px) {
  .lib-detail { grid-template-columns: 220px 1fr; gap: 28px; }
}
@media (max-width: 768px) {
  .lib-wrap { padding: 92px 16px 48px; }
  .lib-reading .lib-wrap { padding: 84px 8px 8px; }
  .lib-reader { height: calc(100vh - 96px); height: calc(100dvh - 96px); border-radius: 6px; }
  .lib-head { flex-direction: column; align-items: flex-start; }
  .lib-title { font-size: 24px; }
  .lib-detail { grid-template-columns: 1fr; gap: 20px; }
  .lib-detail-cover { max-width: 200px; }
  .lib-detail-title { font-size: 25px; }
  .lib-facts { grid-template-columns: repeat(2, 1fr); gap: 14px 20px; }
  .lib-row { gap: 14px; }
  .lib-row .lib-card { width: 122px; }
  .lib-grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 20px 14px; }
  .lib-rd-stage { padding: 14px 16px 18px; gap: 14px; }
  .lib-rd-text { font-size: 20px; }
  .div-kinder .lib-rd-text { font-size: 26px; }
  .div-elem-lower .lib-rd-text { font-size: 23px; }
  .div-elem-upper .lib-rd-text { font-size: 21px; }
  .is-article .lib-rd-text { font-size: 18px; }
}
@media (max-width: 480px) {
  .lib-row .lib-card { width: 108px; }
  .lib-tab { padding: 9px 12px 10px; font-size: 15px; }
  .lib-rd-ctrl { padding: 8px; gap: 6px; }
  .lib-rd-nav { width: 50px; }
  .lib-rd-play, .lib-rd-rate, .lib-rd-ko { padding: 0 11px; font-size: 13.5px; }
  .lib-rd-play { min-width: 66px; }
  .lib-rd-rate { min-width: 54px; }
  .lib-rd-text { font-size: 19px; }
  .div-kinder .lib-rd-text { font-size: 24px; }
  .lib-credits-list > div { grid-template-columns: 68px 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .lib-cover, .lib-rd-bar i, .lib-w { transition: none; }
}

/* 리더를 읽는 동안에는 떠 있는 상담 버튼을 숨긴다(다음 장 버튼을 가림) */
body.lib-reading-on .kakao-float-btn { display: none !important; }
