:root {
  --navy: #1E3A5F;
  --blue: #2563EB;
  --blue-d: #1D4ED8;
  --blue-l: #DBEAFE;
  --blue-b: #93C5FD;
  --text: #1C1F23;
  --text2: #4E5561;
  --text3: #8A9099;
  --line: #E4E7EC;
  --line2: #F0F2F5;
  --fill: #F5F6F8;
  --red: #D4380D;
  --red-l: #FDEDE8;
  --r: 6px;
  --bg-outer: #EDEFF2;
  --highlight: #FFF3A3;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-outer);
  color: var(--text);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Malgun Gothic", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

*:focus-visible {
  outline: 2.5px solid var(--blue);
  outline-offset: 2px;
}

.page {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  background: #fff;
  display: flex;
  flex-direction: column;
}

/* ── 헤더 ── */
.header {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 13px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.header .logo {
  width: 32px; height: 32px; flex: none;
  border-radius: var(--r);
  background: var(--navy);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.header .logo img { width: 100%; height: 100%; object-fit: cover; }
.header .meta { min-width: 0; }
.header .store-name {
  font-size: 16px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.header .store-sub {
  font-size: 12px; color: var(--text3); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── 상단 바(미니 헤더 + 검색창, sticky) ── */
/* 검색 전/후 구조가 같아야 전환할 때 상단이 흔들리지 않는다. */
.stick {
  position: sticky; top: 0; z-index: 20;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.stick[hidden] { display: none; }
.topbar {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 14px 0;
}
.topbar .logo {
  width: 30px; height: 30px; flex: none;
  border-radius: 7px;
  background: var(--navy);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  user-select: none;
}
.topbar .store-name {
  flex: 1 1 auto; min-width: 0;
  font-size: 14.5px; font-weight: 700; letter-spacing: -0.3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── 검색 전 안내 문구 ── */
.hint {
  margin: 16px 20px 0;
  text-align: center;
  font-size: 12.5px;
  color: var(--text3);
  line-height: 1.6;
  word-break: keep-all;
}
.hint b { color: var(--text2); font-weight: 700; }
.hint[hidden] { display: none; }

/* ── 검색 영역 ── */
.searchbar {
  padding: 12px 14px;
}
.search-row {
  display: flex;
  gap: 7px;
}
/* 입력칸 + 직접 그린 지우기(x). 브라우저 기본 x 는 iOS Safari 에 안 나와서 숨기고 우리 것을 쓴다. */
.input-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}
.clear-btn {
  position: absolute;
  right: 0; top: 50%;
  transform: translateY(-50%);
  width: 44px; height: 44px;          /* 탭 영역 최소 44×44 — 42px 칸보다 커서 살짝 튀어나오지만 배경이 없어 티 나지 않는다 */
  padding: 0; border: none; background: none;
  display: flex; align-items: center; justify-content: center;
  color: var(--text3);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.clear-btn:active { color: var(--text2); }
.clear-btn[hidden] { display: none; }

.search-row input[type="search"] {
  width: 100%;
  height: 46px;
  padding: 0 44px 0 14px;             /* 오른쪽은 지우기 버튼 자리 */
  border: 1px solid #C9CDD4;
  border-radius: var(--r);
  font-size: 16px;
  letter-spacing: -0.3px;
  color: var(--text);
  background: #fff;
  font-family: inherit;
}
.search-row input[type="search"]::placeholder { color: #B0B6BE; }
.search-row input[type="search"]:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.search-row input[type="search"]:disabled {
  background: var(--fill);
  color: var(--text3);
}
.search-row button.search-btn {
  flex: none;
  width: 60px; height: 46px;
  border: none;
  border-radius: var(--r);
  background: var(--blue);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  font-family: inherit;
}
.search-row button.search-btn:active { background: var(--blue-d); }
.search-row button.search-btn:disabled { background: #A9C2F5; cursor: default; }

/* ── 저자·위치 칸(접기/펼치기) ── */
.more-fields-btn {
  margin-top: 8px;
  padding: 2px 0;
  border: none; background: none;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; color: var(--blue);
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
}
.more-fields-btn .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--blue);
  margin-right: 2px;
}
.more-fields-btn .dot[hidden] { display: none; }
.more-fields-btn .chevron { transition: transform .15s ease; }
.more-fields-btn.open .chevron { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) {
  .more-fields-btn .chevron { transition: none; }
}
.more-fields {
  margin-top: 8px;
  display: flex; flex-direction: column; gap: 7px;
}
.more-fields[hidden] { display: none; }
.more-fields input[type="search"] {
  width: 100%;
  height: 42px;
  padding: 0 44px 0 14px;             /* 오른쪽은 지우기 버튼 자리 */
  border: 1px solid #C9CDD4;
  border-radius: var(--r);
  font-size: 16px;
  letter-spacing: -0.3px;
  color: var(--text);
  background: #fff;
  font-family: inherit;
}
.more-fields input[type="search"]::placeholder { color: #B0B6BE; }
.more-fields input[type="search"]:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.more-fields input[type="search"]:disabled {
  background: var(--fill);
  color: var(--text3);
}

/* 로딩이 끝나도 자리를 비우지 않는다(display:none 이면 아래 내용이 11px 위로 튄다). */
.progress-bar {
  height: 3px;
  border-radius: 2px;
  background: var(--line2);
  margin-top: 8px;
  overflow: hidden;
  visibility: hidden;
}
.progress-bar.active { visibility: visible; }
/* 안 보이는 동안 애니메이션까지 계속 돌 이유는 없다. */
.progress-bar:not(.active) > span { animation-play-state: paused; }
.progress-bar > span {
  display: block;
  height: 100%;
  width: 40%;
  background: var(--blue);
  border-radius: 2px;
  animation: progress-slide 1.1s ease-in-out infinite;
}
@keyframes progress-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ── 폴백 안내(권수 정확 일치가 없어 비슷한 결과를 보여줄 때) ── */
.fallback-notice {
  margin: 12px 14px 0;
  padding: 11px 13px;
  border-radius: 6px;
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  font-size: 13px;
  color: #854D0E;
  line-height: 1.5;
}

/* ── 결과 헤더 ── */
.result-header {
  padding: 14px 16px 8px;
  font-size: 13px;
  color: var(--text3);
  display: flex;
  justify-content: space-between;
}
.result-header b { color: var(--text); font-weight: 700; }

/* ── 결과 목록(한 줄 = DB 한 행) ── */
/* 결과가 수천 건이므로 카드 대신 구분선만 있는 목록으로, 행 높이를 60px 아래로 누른다. */
.result-list {
  padding: 0 14px 4px;
}
.row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line2);
}
.row-main { flex: 1; min-width: 0; }
/* 제목만 줄이고(말줄임) 완결 배지는 항상 남긴다 — 배지까지 잘려 나가면 안 되므로 flex 로 나눈다. */
.row-title {
  display: flex; align-items: center; gap: 6px;
  font-size: 15.5px; font-weight: 600; color: var(--text);
  letter-spacing: -0.3px; line-height: 1.2;
}
.row-title-text {
  min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-title mark { background: var(--highlight); border-radius: 2px; }
.badge-done {
  flex: none;
  padding: 1px 5px; border-radius: 3px;
  background: var(--fill); color: var(--text2);
  font-size: 11px; font-weight: 700; line-height: 1.3;
}
.row-sub {
  margin-top: 2px;
  font-size: 12.5px; color: var(--text3); line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* 위치는 DB 문자열 그대로. "코믹 아-5" 처럼 공백이 있어도 줄이 바뀌면 안 되고,
   표시 전용이라 길게 눌러도 선택 메뉴가 뜨지 않게 한다(iOS 16.3 이하용 -webkit- 포함). */
.row-loc {
  flex: none;
  min-width: 64px;
  text-align: right;
  font-size: 14px; font-weight: 700; color: var(--blue);
  white-space: nowrap;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ── 더 보기(50건씩 이어 그리기) ── */
.load-more {
  width: 100%;
  min-height: 44px;
  padding: 11px 0;
  border: none;
  border-top: 1px solid var(--line2);
  background: var(--fill);
  font-size: 13.5px; font-weight: 700; color: var(--blue);
  cursor: pointer;
  font-family: inherit;
}
.load-more:active { background: var(--blue-l); }
.load-more[hidden] { display: none; }

/* ── 초기 화면 / 결과 없음 ── */
.empty-block {
  padding: 30px 20px 26px;
  text-align: center;
}
.empty-block h2 { font-size: 17px; font-weight: 700; margin: 0 0 8px; }
.empty-block p { font-size: 14px; color: var(--text2); line-height: 1.65; margin: 0; }

.tip-box {
  margin-top: 18px;
  background: var(--fill);
  border-radius: var(--r);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text2);
  line-height: 1.8;
  text-align: left;
}

/* ── 연령 제한 안내 ── */
.age-notice {
  margin: 2px 14px 20px;
  padding: 12px 13px;
  border-radius: 6px;
  background: var(--fill);
  border: 1px solid var(--line);
}
.age-notice-title {
  margin: 0;
  font-size: 13.5px; font-weight: 700; color: var(--text);
}
.age-notice-desc {
  margin: 4px 0 0;
  font-size: 13px; color: var(--text2);
  line-height: 1.6;
}

/* ── 실패 화면 ── */
.fail-block {
  padding: 60px 24px;
  text-align: center;
}
.fail-block h2 { font-size: 17px; font-weight: 700; margin: 0 0 8px; }
.fail-block p { font-size: 14px; color: var(--text2); margin: 0 0 20px; }
.retry-btn {
  padding: 11px 24px;
  border: none; border-radius: var(--r);
  background: var(--blue); color: #fff;
  font-size: 15px; font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.retry-btn:active { background: var(--blue-d); }
.fail-block .fail-hint { font-size: 12px; color: var(--text3); margin: 14px 0 0; }

/* ── 광고 영역 ── */
.ad {
  margin: auto 14px 0;
  padding-top: 22px;
  flex: none;
}
.page.searched .ad {
  margin-top: 16px;
}
.ad-label {
  font-size: 11px; color: #B7BCC4; margin-bottom: 5px; letter-spacing: -0.2px;
}
.ad-box {
  height: 100px;
  border: 1px dashed #C9CDD4;
  border-radius: var(--r);
  background: var(--fill);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: #A9AEB7; font-weight: 600;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap;
}
