/* code.libera.kr — 서재 + EPUB형 리더 */

body.code-reader-page .wrap {
  max-width: none;
  padding: 0;
}

.code-library {
  max-width: 1100px;
  margin: 0 auto;
  padding: 8px 16px 48px;
}

.code-home-hero {
  margin: 4px 0 28px;
  padding: 4px 0 22px;
  border-bottom: 1px solid var(--line, #ddd8ce);
}

.code-home-title {
  margin: 0 0 12px;
  font-size: clamp(1.55rem, 2.4vw, 1.95rem);
  letter-spacing: -0.03em;
  line-height: 1.25;
}

.code-home-lead {
  margin: 0 0 8px;
  max-width: 42rem;
  font-size: 1.02rem;
  line-height: 1.65;
  color: var(--ink, #1a1a1a);
}

.code-home-lead strong {
  font-weight: 800;
}

.code-home-lead-sub {
  margin: 0;
  max-width: 42rem;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--muted, #666);
}

.code-home-section {
  margin: 0 0 36px;
}

.code-home-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 16px;
}

.code-home-section-head h3,
.code-home-about h3 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.code-home-section-meta {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted, #666);
}

.code-home-about {
  max-width: 40rem;
  padding: 20px 0 0;
  border-top: 1px solid var(--line, #ddd8ce);
}

.code-home-steps {
  margin: 12px 0 16px;
  padding-left: 1.25rem;
  line-height: 1.7;
}

.code-home-steps li {
  margin: 0 0 4px;
}

.code-home-note {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--muted, #666);
}

.code-home-note a {
  color: var(--accent, #0a6b56);
}

.code-library-head {
  margin: 8px 0 20px;
}

.code-library-head h2 {
  margin: 0 0 6px;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}

.code-library-head p {
  margin: 0;
  color: var(--muted, #64748b);
}

.code-library-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 20px;
  list-style: none;
  margin: 0;
  padding: 0;
}

@media (max-width: 960px) {
  .code-library-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .code-library-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
  }
}

@media (max-width: 480px) {
  .code-library-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
}

.code-library-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 12px;
  background: #fff;
  text-decoration: none;
  color: inherit;
  min-height: 140px;
  min-width: 0;
  width: 100%;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.code-library-card.has-cover {
  padding: 0;
  min-height: 0;
  overflow: hidden;
  border: none;
  background: transparent;
  gap: 10px;
}

.code-library-card:hover {
  border-color: var(--accent, #0a7a5c);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}

.code-library-card.has-cover:hover {
  border-color: transparent;
  box-shadow: none;
}

.code-library-card.has-cover:hover .code-library-card-cover {
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.14);
  transform: translateY(-2px);
}

.code-library-card-cover {
  display: block;
  aspect-ratio: 5 / 8;
  border-radius: 8px;
  overflow: hidden;
  background: #e8eef3;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.code-library-card-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.code-library-card-title {
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.code-library-card-title-sm {
  display: block;
  font-weight: 650;
  font-size: 0.92rem;
  color: inherit;
  line-height: 1.3;
  margin-bottom: 2px;
  letter-spacing: -0.01em;
}

.code-library-card-meta {
  margin-top: auto;
  font-size: 0.85rem;
  color: var(--muted, #64748b);
}

.code-library-card.has-cover .code-library-card-meta {
  margin-top: 0;
  padding: 0 2px;
}

.code-library-empty {
  padding: 32px 8px;
  color: var(--muted, #64748b);
}

.code-library-lead {
  margin: 0 0 18px;
  font-size: 0.95rem;
}

.code-library-card-author {
  display: inline;
}

.code-reader-cover-page .code-reader-cover-frame {
  margin: 12px 0 28px;
  max-width: min(420px, 100%);
}

.code-reader-cover-page .code-reader-cover-frame img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.12);
}

.code-reader-stores {
  margin: 0 0 24px;
  max-width: min(420px, 100%);
}

.code-reader-stores-title {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink, #1e293b);
}

.code-reader-stores-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
}

.code-reader-stores-list a {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid var(--line, #d6d3cd);
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.9rem;
  color: var(--ink, #1e293b);
  background: #fff;
}

.code-reader-stores-list a:hover {
  border-color: var(--accent, #0a7a5c);
  color: var(--accent, #0a7a5c);
}

.code-reader-toc-stores {
  margin: 0;
  padding: 12px 16px 18px;
  border-top: 1px solid var(--line, #e2e8f0);
}

.code-reader-toc-stores-label {
  margin: 0 0 6px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted, #64748b);
}

.code-reader-toc-stores ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.code-reader-toc-stores a {
  display: block;
  padding: 4px 0;
  font-size: 0.88rem;
  color: var(--accent, #0a7a5c);
  text-decoration: none;
}

.code-reader-toc-stores a:hover {
  text-decoration: underline;
}

.code-reader-nav .toc-cover .toc-num {
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

/* Reader shell */
.code-reader {
  display: grid;
  grid-template-columns: minmax(220px, 300px) 1fr;
  min-height: calc(100vh - 120px);
  border-top: 1px solid var(--line, #e2e8f0);
}

.code-reader-toc {
  border-right: 1px solid var(--line, #e2e8f0);
  background: #fafaf8;
  overflow: auto;
  max-height: calc(100vh - 120px);
  position: sticky;
  top: 0;
}

.code-reader-toc-head {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line, #e2e8f0);
}

.code-reader-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin-bottom: 8px;
  border-radius: 8px;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--ink, #1e293b);
  text-decoration: none;
}
.code-reader-back:hover {
  background: rgba(10, 122, 92, 0.1);
  color: var(--accent, #0a7a5c);
}

.code-reader-book-title {
  margin: 0 0 4px;
  font-size: 1.05rem;
  line-height: 1.35;
}

.code-reader-meta {
  margin: 0;
  font-size: 0.8rem;
}

.code-reader-nav {
  padding: 8px 0 24px;
}

.code-reader-nav ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

.code-reader-nav li a,
.code-reader-nav li .toc-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 14px;
  text-decoration: none;
  color: var(--ink, #1e293b);
  font-size: 0.9rem;
  line-height: 1.4;
  border-left: 3px solid transparent;
}

.code-reader-nav li a:hover {
  background: rgba(10, 122, 92, 0.06);
}

.code-reader-nav li.is-active a {
  background: rgba(10, 122, 92, 0.1);
  border-left-color: var(--accent, #0a7a5c);
  font-weight: 700;
}

/* 장 제목 비공개·하위만 공개: 번호+이름만(링크·본문·주소 없음) */
.code-reader-nav li.toc-nolink .toc-row {
  color: var(--ink, #1e293b);
  cursor: default;
}

.code-reader-nav .toc-num {
  flex-shrink: 0;
  min-width: 1.8em;
  color: var(--muted, #64748b);
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
}

/* class lesson list depth — indent subsections like list.php */
.code-reader-nav li.toc-depth-1 a,
.code-reader-nav li.toc-depth-1 .toc-row {
  padding-left: 28px;
}
.code-reader-nav li.toc-depth-2 a,
.code-reader-nav li.toc-depth-2 .toc-row {
  padding-left: 42px;
}
.code-reader-nav li.toc-depth-1 .toc-title,
.code-reader-nav li.toc-depth-2 .toc-title {
  font-weight: 500;
}
.code-reader-nav li.toc-depth-1.is-active .toc-title,
.code-reader-nav li.toc-depth-2.is-active .toc-title {
  font-weight: 700;
}

.code-reader-main {
  padding: 20px 28px 48px;
  overflow: auto;
  max-width: 820px;
}

.code-reader-chapter-title {
  margin: 0 0 8px;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.code-reader-chapter-meta {
  margin: 0 0 18px;
  font-size: 0.85rem;
}

.code-reader-body {
  line-height: 1.7;
}

/* 본문 문단: class mybook / EPUB p.body(0.75em)에 맞춤. br 줄간격은 그대로 */
.code-reader-body p.body,
.code-reader-body p {
  margin: 0.75em 0;
  line-height: 1.7;
}
/* 공통 상자 (class mybook / EPUB과 동일 팔레트) */
.code-reader-body .box {
  margin: 0.8em 0;
  padding: 0.65em 0.8em;
  border: 2px solid #4a5568;
  border-radius: 4px;
  background-color: #f7fafc;
  box-sizing: border-box;
}
.code-reader-body .box p {
  margin: 0 0 0.4em 0;
  line-height: 1.6;
  text-align: left;
}
.code-reader-body .box p:last-child {
  margin-bottom: 0;
}
.code-reader-body .box .box-title {
  margin: 0 0 0.4em 0;
  font-weight: bold;
  line-height: 1.45;
}
.code-reader-body .box .box-subtitle {
  margin: 0 0 0.45em 0;
  font-weight: 600;
  font-size: 0.95em;
  line-height: 1.4;
  color: #6b5e52;
}
.code-reader-body .box-concept { border-color: #2b6cb0; background-color: #ebf4ff; }
.code-reader-body .box-concept .box-title { color: #1e4e8c; }
.code-reader-body .box-error { border-color: #c53030; background-color: #fff5f5; }
.code-reader-body .box-error .box-title { color: #9b2c2c; }
.code-reader-body .box-caution { border-color: #c05621; background-color: #fffaf0; }
.code-reader-body .box-caution .box-title { color: #7b341e; }
.code-reader-body .box-practice { border-color: #6b46c1; background-color: #faf5ff; }
.code-reader-body .box-practice .box-title { color: #44337a; }
.code-reader-body .box-tip { border-color: #2f855a; background-color: #f0fff4; }
.code-reader-body .box-tip .box-title { color: #22543d; }
.code-reader-body .box-version { border-color: #2c7a7b; background-color: #e6fffa; }
.code-reader-body .box-version .box-title { color: #234e52; }
.code-reader-body .box-rest {
  border-color: #9c8b7a;
  background-color: #f7f3ee;
  font-size: 0.92em;
}
.code-reader-body .box-rest .box-title { color: #5f5246; }
.code-reader-body .box-rest .box-subtitle { color: #6b5e52; }
.code-reader-body .box .box-disclaimer {
  margin: 0.55em 0 0 0;
  font-size: 0.85em;
  line-height: 1.5;
  color: #6b5e52;
  overflow-wrap: break-word;
}
.code-reader-body .box .box-disclaimer small {
  font-size: inherit;
  color: inherit;
}
.code-reader-body ol,
.code-reader-body ul {
  margin: 0.75em 0;
  padding-left: 1.5em;
}
.code-reader-body ol.step-list,
.code-reader-body ul.step-list {
  margin: 0.75em 0;
}
.code-reader-body ol > li,
.code-reader-body ul > li {
  margin: 0.3em 0;
}

/* 명세·실행확인 목록 (ul.spec-list) — class 사이트·EPUB과 동일 간격 */
.code-reader-body ul.spec-list {
  margin: 0.9em 0;
  padding-left: 1.35em;
  list-style-type: disc;
}
.code-reader-body ul.spec-list > li {
  margin: 0.85em 0;
}
.code-reader-body ul.spec-list > li > ul {
  margin: 0.4em 0 0.1em;
  padding-left: 1.25em;
  list-style-type: circle;
}
.code-reader-body ul.spec-list > li > ul > li {
  margin: 0.35em 0;
}
.code-reader-body ul.spec-list strong,
.code-reader-body ul.spec-list b {
  font-weight: 700;
}

/* 바뀐 줄: 굵기 + 글자색만 (배경·패딩·라운드 없음) */
.code-reader-body div.code .is-bold,
.code-reader-body div.code.codeback1 .is-bold {
  font-family: "Nanum Gothic Coding", "NanumGothicCoding", consolas, monospace;
  font-weight: 700;
  font-synthesis: weight;
  color: #d4788a;
}
.code-reader-body div.code.codeback2 .is-bold {
  font-family: "Nanum Gothic Coding", "NanumGothicCoding", consolas, monospace;
  font-weight: 700;
  font-synthesis: weight;
  color: #6b9bc4;
}

/* 콘솔 핵심 메시지 (is-key). 밑줄+윤곽, 배경 없음 */
.code-reader-body div.code .is-key,
.code-reader-body div.code p.is-key {
  text-decoration: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.12em;
  outline: 1px solid currentColor;
  outline-offset: 1px;
}

/* 본문 표 + 짧은 열 고정 */
.code-reader-body table.tbl,
.code-reader-body table.epub-table {
  width: 100%;
  max-width: 100%;
  margin: 0.75em 0;
  border-collapse: collapse;
  font-size: 0.95em;
}
.code-reader-body table.tbl th,
.code-reader-body table.tbl td,
.code-reader-body table.epub-table th,
.code-reader-body table.epub-table td {
  border: 1px solid #999;
  padding: 0.4em;
  text-align: left;
  vertical-align: top;
  word-break: break-word;
  overflow-wrap: break-word;
}
.code-reader-body table.tbl th.tbl-narrow,
.code-reader-body table.tbl td.tbl-narrow,
.code-reader-body table.epub-table th.tbl-narrow,
.code-reader-body table.epub-table td.tbl-narrow,
.code-reader-body table.tbl:has(tr > :nth-child(9):last-child) tr > :nth-child(n + 2):nth-child(-n + 7),
.code-reader-body table.epub-table:has(tr > :nth-child(9):last-child) tr > :nth-child(n + 2):nth-child(-n + 7) {
  width: 1%;
  white-space: nowrap;
  word-break: keep-all;
  overflow-wrap: normal;
}
.code-reader-body table.tbl th,
.code-reader-body table.epub-table th {
  background-color: #f2f2f2;
  font-weight: bold;
}

.code-reader-pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 36px;
  padding-top: 16px;
  border-top: 1px solid var(--line, #e2e8f0);
}

.code-reader-pager .btn {
  max-width: 46%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 챕터 본문 아래 댓글 (한국어 UI, engage 공용 스타일 사용) */
.code-reader-main .engage-comments {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--line, #e2e8f0);
  max-width: 42rem;
}

@media (max-width: 800px) {
  .code-reader {
    grid-template-columns: 1fr;
  }
  .code-reader-toc {
    position: relative;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line, #e2e8f0);
  }
  .code-reader-nav {
    max-height: 220px;
    overflow: auto;
  }
  .code-reader-main {
    padding: 16px;
  }
}
