:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-strong: #fffaf0;
  --ink: #1f2933;
  --muted: #667085;
  --line: #ded8ce;
  --line-strong: #c7bfb2;
  --accent: #2f6f73;
  --accent-strong: #204f52;
  --accent-soft: #dceced;
  --gold: #9b6a1b;
  --green: #3e7654;
  --rose: #a85757;
  --blue: #486aa8;
  --shadow: 0 18px 45px rgba(31, 41, 51, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.65), rgba(246, 244, 239, 0) 340px),
    var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", "Apple SD Gothic Neo", sans-serif;
  line-height: 1.55;
}

a {
  color: inherit;
}

button {
  font: inherit;
}

.site-shell {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid rgba(222, 216, 206, 0.85);
  background: rgba(246, 244, 239, 0.92);
  backdrop-filter: blur(14px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--accent);
  color: #ffffff;
  font-size: 15px;
  letter-spacing: 0;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ghost-link {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.58);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 28px;
  align-items: end;
  padding: 54px 0 28px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
}

.hero h1 {
  max-width: 720px;
  margin: 0;
  font-size: clamp(34px, 5vw, 62px);
  line-height: 1.08;
  letter-spacing: 0;
}

.hero p {
  max-width: 700px;
  margin: 18px 0 0;
  color: #4d5965;
  font-size: 18px;
}

.hero-panel {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  min-height: 82px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfaf7;
}

.stat strong {
  display: block;
  font-size: 28px;
  line-height: 1;
}

.stat span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.control-band {
  margin: 22px auto 26px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.82);
}

.filter-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.filter-kicker {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.filter-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.result-count {
  min-width: 116px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  text-align: right;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.filter-button {
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: #46515d;
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
}

.filter-button:hover,
.filter-button:focus {
  border-color: var(--accent);
}

.filter-button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.library {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding-bottom: 52px;
}

.book-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 10px 26px rgba(31, 41, 51, 0.05);
  overflow: clip;
}

.book-card.hidden {
  display: none;
}

.book-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  padding: 20px 20px 14px;
}

.book-kicker {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.book-title {
  margin: 0;
  font-size: 23px;
  line-height: 1.22;
  letter-spacing: 0;
}

.book-desc {
  margin: 10px 0 0;
  color: #596673;
  font-size: 15px;
}

.book-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.category-pill,
.count-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 6px;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 900;
}

.category-pill {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.count-pill {
  background: #f3eee4;
  color: #6d5840;
}

.book-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 20px 16px;
}

.book-tags span {
  min-height: 26px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.book-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: #fbfaf7;
}

.primary-link,
.secondary-link,
.chapter-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 900;
  text-decoration: none;
}

.primary-link {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.secondary-link,
.chapter-toggle {
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: #4b5563;
}

.chapter-toggle {
  cursor: pointer;
}

.chapter-list {
  display: none;
  max-height: 360px;
  overflow: auto;
  padding: 4px 20px 18px;
  border-top: 1px solid var(--line);
}

.book-card.expanded .chapter-list {
  display: grid;
  gap: 7px;
}

.chapter-link {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #344054;
  text-decoration: none;
}

.chapter-link:hover,
.chapter-link:focus {
  border-color: var(--line);
  background: #fbfaf7;
}

.chapter-no {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.chapter-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 700;
}

.empty-state {
  display: none;
  padding: 34px;
  margin-bottom: 52px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.empty-state.visible {
  display: block;
}

.footer {
  padding: 28px 0 42px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 860px) {
  .site-shell {
    width: min(100% - 24px, 1180px);
  }

  .hero {
    grid-template-columns: 1fr;
    padding-top: 34px;
  }

  .hero h1 {
    font-size: 40px;
  }

  .library {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar-inner,
  .filter-row,
  .book-head {
    grid-template-columns: 1fr;
  }

  .topbar-inner {
    align-items: flex-start;
    padding: 12px 0;
  }

  .top-actions {
    width: 100%;
  }

  .ghost-link {
    width: 100%;
    text-align: center;
  }

  .filter-row {
    display: grid;
  }

  .result-count {
    min-width: 0;
    text-align: left;
  }

  .hero h1 {
    font-size: 34px;
  }

  .hero p {
    font-size: 16px;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }

  .book-meta {
    align-items: flex-start;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .book-actions {
    display: grid;
  }

  .primary-link,
  .secondary-link,
  .chapter-toggle {
    width: 100%;
  }

  .chapter-link {
    grid-template-columns: 42px minmax(0, 1fr);
  }
}
