/* EBOOK — 색은 전부 토큰. 테마는 <html data-theme="light|sepia|dark">, 없으면 시스템 설정을 따른다. */
:root {
  --bg: #faf8f5; --surface: #ffffff; --text: #1f1d1a; --muted: #6b665e; --line: #e8e3da;
  --accent: #c2410c; --accent-ink: #ffffff; --focus: #2563eb;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 6px 18px rgba(0,0,0,.06);
  --reader-fs: 18px;
  --sans: system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  --serif: "Noto Serif KR", "Nanum Myeongjo", "Apple SD Gothic Neo", Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #14130f; --surface: #1d1b16; --text: #ece8df; --muted: #a29b8d; --line: #2e2b24;
    --accent: #fb923c; --accent-ink: #1a0f05; --focus: #7aa7ff; --shadow: 0 1px 2px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="sepia"] {
  --bg: #f4ecd8; --surface: #fbf5e6; --text: #43382a; --muted: #7b6d58; --line: #e1d5b8;
  --accent: #9a3412; --accent-ink: #fffaf0;
}
:root[data-theme="dark"] {
  --bg: #14130f; --surface: #1d1b16; --text: #ece8df; --muted: #a29b8d; --line: #2e2b24;
  --accent: #fb923c; --accent-ink: #1a0f05; --focus: #7aa7ff; --shadow: 0 1px 2px rgba(0,0,0,.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.65 var(--sans); }
a { color: inherit; }
img, svg { max-width: 100%; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px 48px; }

/* 헤더 */
.site-header {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .04em; text-decoration: none; color: var(--accent); }
.header-actions { display: flex; align-items: center; gap: 6px; }
.btn-icon {
  min-width: 44px; height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; cursor: pointer;
}
.btn-icon:hover { border-color: var(--accent); }

/* 버튼 */
.btn, .btn-link {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-link { border: 0; background: none; color: var(--muted); }

/* 히어로 / 검색 */
.hero { max-width: 1040px; margin: 0 auto; padding: 40px 16px 8px; }
.hero h1 { margin: 0 0 10px; font: 800 clamp(1.8rem, 5vw, 2.8rem)/1.2 var(--serif); letter-spacing: -.01em; }
.lead { margin: 0 0 20px; color: var(--muted); max-width: 40em; }
.search { display: flex; gap: 8px; max-width: 520px; }
.search input[type="search"] {
  flex: 1; min-width: 0; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text); font: inherit;
}

/* 분류 칩 */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 24px 0 12px; }
.chip {
  padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  font-size: 14px; text-decoration: none;
}
.chip small { color: var(--muted); margin-left: 2px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.on small { color: inherit; opacity: .8; }
.result-meta { margin: 0 0 14px; color: var(--muted); font-size: 14px; }

/* 카드 그리드 */
.grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.card { display: block; text-decoration: none; }
.card:hover .cover { transform: translateY(-3px); }
.card-body h2 { margin: 10px 0 2px; font-size: 15px; line-height: 1.35; }
.card-body p { margin: 0; font-size: 13px; }
.price { margin-top: 2px; font-weight: 700; color: var(--accent); }

/* 커버 */
.cover {
  position: relative; aspect-ratio: 2 / 3; display: flex; flex-direction: column; justify-content: space-between;
  padding: 14px 12px 12px 18px; border-radius: 4px 10px 10px 4px; color: #fff;
  background: linear-gradient(150deg, var(--c1), var(--c2));
  box-shadow: var(--shadow), inset 6px 0 0 rgba(0,0,0,.14); transition: transform .15s ease;
}
.cover-cat { font-size: 11px; letter-spacing: .08em; opacity: .85; }
.cover-title { font: 800 clamp(15px, 2.2vw, 19px)/1.3 var(--serif); text-wrap: balance; text-shadow: 0 1px 2px rgba(0,0,0,.25); }
.cover-author { font-size: 11px; opacity: .9; }
.cover-big { width: 220px; flex: none; padding: 20px 16px 16px 24px; }
.cover-big .cover-title { font-size: 24px; }

/* 도서 상세 */
.crumb { margin: 20px 0 14px; font-size: 14px; color: var(--muted); }
.crumb a { text-decoration: none; }
.crumb a:hover { color: var(--accent); }
.book-head { display: flex; gap: 28px; align-items: flex-start; }
.book-info { flex: 1; min-width: 0; }
.book-info h1 { margin: 0 0 4px; font: 800 clamp(1.5rem, 4vw, 2.1rem)/1.25 var(--serif); }
.meta { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 16px 0; }
.meta div { display: flex; gap: 8px; }
.meta dt { color: var(--muted); font-size: 14px; }
.meta dd { margin: 0; font-weight: 600; font-size: 14px; }
.summary { margin: 0 0 14px; max-width: 38em; }
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 20px; padding: 0; }
.tags a { color: var(--accent); font-size: 14px; text-decoration: none; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.toc { margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--line); }
.toc h2 { margin: 0 0 8px; font-size: 18px; }
.toc h2 small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li a { display: block; padding: 12px 4px; border-bottom: 1px solid var(--line); text-decoration: none; }
.toc li a:hover { color: var(--accent); }

/* 빈 화면 / 404 */
.empty { text-align: center; padding: 56px 16px; }
.empty h1 { font: 800 1.6rem/1.3 var(--serif); margin: 0 0 8px; }

/* 리더 */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 20; background: transparent; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .1s linear; }
.page { max-width: 38em; margin: 0 auto; padding: 8px 20px 24px; font: var(--reader-fs)/1.95 var(--serif); }
.page h1 { margin: 12px 0 28px; font: 800 1.45em/1.35 var(--serif); }
.page p { margin: 0 0 1.3em; text-align: justify; word-break: keep-all; overflow-wrap: break-word; }
.page .crumb { font: 14px/1.5 var(--sans); }
.pager {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  max-width: 38em; margin: 0 auto; padding: 8px 20px 64px;
}

.site-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; max-width: 1040px; margin: 0 auto; padding: 20px 16px 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

@media (max-width: 640px) {
  .book-head { flex-direction: column; align-items: center; text-align: center; gap: 20px; }
  .book-info { width: 100%; }
  .meta, .tags, .actions { justify-content: center; }
  .summary { margin-inline: auto; }
  .cover-big { width: 180px; }
  .search { max-width: none; }
  .page { padding-inline: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .cover, .progress i { transition: none; }
}
