/* ===== 영어책 리더 ===== */
:root {
  --bg: #12100e;
  --surface: #1c1917;
  --surface-2: #262220;
  --text: #f5f1ec;
  --text-dim: #a39a91;
  --accent: #e0805c;
  --accent-soft: rgba(224, 128, 92, .16);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Noto Sans KR', sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* --- 상단 바 --- */
.top-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--surface-2);
  flex: none;
}
.top-bar h1 { font-size: 20px; margin: 0; flex: 1; }
.reader-title {
  flex: 1;
  font-size: 15px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.icon-btn {
  background: none; border: none;
  color: var(--text);
  font-size: 20px;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 8px;
}
.icon-btn:active { background: var(--surface-2); }

/* --- 서재 --- */
.book-grid {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 14px 0 20px;
}
.book-card {
  cursor: pointer; border: none; background: none; padding: 0;
  text-align: left; color: inherit; width: 100%;
  /* 버튼은 font 를 상속하지 않는다. 이게 없으면 카드 안 글자가
     브라우저 기본 폼 폰트(Arial)로 떨어져 프리텐다드가 안 걸린다. */
  font: inherit;
}

/* 유튜브 썸네일 문법. 16:9 전폭 그림 위에 한글 타이포를 얹는다.
   그림에는 글자를 그리지 않는다 — 이미지 모델이 한글을 못 쓰기 때문이다.
   여기서 얹으면 늘 정확하고, 제목을 고쳐도 표지를 다시 안 만들어도 된다. */
.book-card-cover {
  position: relative;
  /* 제목 크기의 기준. vw(화면 폭)로 재면 2열에서는 카드가 반쪽이라
     글자가 상대적으로 커 보이고 1열에서는 작아 보인다.
     카드 폭(cqw) 기준이면 열 수와 무관하게 늘 같은 비율이다. */
  container-type: inline-size;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--surface-2) center/cover no-repeat;
  overflow: hidden;
}

/* 아래쪽을 눌러 글자를 살린다. 그림이 밝게 나와도 제목이 읽혀야 한다. */
.book-card-scrim {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top, rgba(8,6,5,.88) 0%, rgba(8,6,5,.52) 30%, rgba(8,6,5,0) 58%);
  pointer-events: none;
}

/* 유튜브 썸네일 타이포. 두 줄, 아래줄에 형광 강조색.
   스트로크가 있어야 어떤 그림 위에서도 글자가 뜬다. */
.book-card-title {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  margin: 0;
  padding: 0 14px 12px;
  font-size: clamp(27px, 10.5cqw, 48px);   /* 2열일 때의 카드 대비 비율(≈11%)을 기준으로 맞췄다 */
  font-weight: 900;
  line-height: 1.14;
  transition: font-size .12s;
  letter-spacing: -.045em;      /* 프리텐다드는 바짝 조여야 시원하다 */
  word-break: keep-all;         /* 한국어는 어절로 끊어야 읽힌다 */
}
.book-card-title .tl {
  display: block;
  color: #fff;
  /* paint-order 가 없으면 외곽선이 글자 속을 파먹어 획이 가늘어진다 */
  paint-order: stroke fill;
  -webkit-text-stroke: 5px rgba(6, 4, 3, .92);
  text-shadow: 0 3px 12px rgba(0, 0, 0, .8);
}
.book-card-title .tl-2 { color: var(--hook, #ffe14d); }

/* 세 줄이 되면 한 단계 줄인다. 그대로 두면 그림을 다 덮는다.
   줄 수는 렌더 뒤에 재야 알 수 있어서 JS 가 이 클래스를 붙인다. */
.book-card-title.is-long {
  font-size: clamp(23px, 9.3cqw, 42px);   /* 축소돼도 예전 기본 크기보다는 커야 체감이 유지된다 */
  line-height: 1.18;
}
.book-card-meta { margin: 7px 16px 0; font-size: 12px; color: var(--text-dim); }

/* 화면이 넓으면 두 줄씩 — 폰에서는 한 줄이 유튜브와 같은 리듬이다 */
@media (min-width: 640px) {
  .book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 26px 16px;
    padding: 16px 8px 24px;
  }
  .book-card-cover { border-radius: var(--radius); }
}

/* --- 리더 레이아웃: 본문은 스크롤, 재생바는 하단 고정 --- */
#reader-view {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.progress-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  font-size: 12px; color: var(--text-dim);
  flex: none;
}
/* 진행바 — 손가락으로 잡아 끌 수 있어야 하므로 실제 막대보다 넉넉한 터치 영역을 준다 */
.progress-track {
  position: relative;
  flex: 1;
  height: 3px;
  background: var(--surface-2);
  border-radius: 2px;
  cursor: pointer;
  touch-action: none;      /* 끄는 동안 페이지가 같이 스크롤되지 않게 */
}
.progress-track::before {   /* 보이지 않는 터치 영역 */
  content: '';
  position: absolute;
  inset: -16px 0;
}
.progress-track:focus-visible { outline: 2px solid var(--accent); outline-offset: 8px; }

#progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 2px;
  transition: width .25s;
}
.progress-track.scrubbing #progress-fill { transition: none; }

.progress-knob {
  position: absolute;
  top: 50%;
  left: 0;
  width: 11px; height: 11px;
  margin: -5.5px 0 0 -5.5px;
  border-radius: 50%;
  background: var(--accent);
  transform: scale(0);
  transition: transform .15s, left .25s;
  pointer-events: none;
}
.progress-track:hover .progress-knob,
.progress-track.scrubbing .progress-knob { transform: scale(1); }
.progress-track.scrubbing .progress-knob { transition: transform .15s; }

/* 끄는 동안 어디로 가는지 보여 주는 말풍선 */
.scrub-preview {
  position: absolute;
  bottom: 18px;
  transform: translateX(-50%);
  background: var(--surface-2);
  color: var(--text);
  font-size: 11px;
  padding: 5px 9px;
  border-radius: 7px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 3px 10px rgba(0,0,0,.4);
}

/* --- 보기 토글 --- */
.view-toggle {
  display: flex;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 2px;
  flex: none;
}
.vt {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}
.vt.active { background: var(--accent); color: #1a1512; font-weight: 600; }

/* --- 문장별로 보기 --- */
.sentence-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px 26px;
  text-align: center;
  overflow-y: auto;
}
.solo-en {
  margin: 0;
  font-size: clamp(22px, 6vw, 32px);
  line-height: 1.45;
  font-weight: 600;
}
.solo-ko {
  margin: 0;
  font-size: clamp(14px, 3.8vw, 18px);
  line-height: 1.55;
  color: var(--text-dim);
  transition: opacity .2s;
}
.solo-ko.veiled { opacity: .16; filter: blur(4px); }

/* --- 책 본문 --- */
.page-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 24px 28px;
  -webkit-overflow-scrolling: touch;
}
.page-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: .02em;
  margin: 0 0 20px;
}
.page-text {
  font-size: 19px;
  line-height: 1.95;
  font-family: 'Georgia', 'Times New Roman', serif;
  word-break: keep-all;
}
/* 책 소개(한국어 요약) — 본문 서체 대신 한글용 */
.page-text.summary {
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Noto Sans KR', sans-serif;
  font-size: 16px;
  line-height: 1.85;
  color: var(--text-dim);
}
.page-text.summary .sent.current { color: var(--accent); }
.solo-en.summary {
  font-size: clamp(17px, 4.4vw, 22px);
  font-weight: 500;
  line-height: 1.65;
  color: var(--text-dim);
}

/* 문장 단위 하이라이트 */
.sent {
  cursor: pointer;
  border-radius: 4px;
  padding: 1px 2px;
  transition: background .18s, color .18s;
}
.sent:active { background: var(--surface-2); }
.sent.current {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* --- 하단 재생 바 --- */
.player-bar {
  flex: none;
  background: var(--surface);
  border-top: 1px solid var(--surface-2);
  padding: 12px 16px calc(10px + env(safe-area-inset-bottom));
}
.now-ko {
  margin: 0 0 10px;
  text-align: center;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-dim);
  min-height: 21px;
  transition: opacity .2s;
}
.now-ko.veiled { opacity: .16; filter: blur(4px); }

.repeat-dots { display: flex; gap: 7px; justify-content: center; margin-bottom: 10px; min-height: 7px; }
.repeat-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--surface-2); }
.repeat-dots span.on { background: var(--accent); }
.repeat-dots span.ko { background: var(--text-dim); }

.controls {
  display: flex; align-items: center; justify-content: center;
  gap: 14px;
  margin-bottom: 10px;
}
.ctl {
  background: var(--surface-2); border: none; color: var(--text);
  width: 48px; height: 48px; border-radius: 50%;
  font-size: 17px; cursor: pointer;
  font-family: inherit;
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.ctl:active { opacity: .7; }
.ctl-main {
  width: 64px; height: 64px;
  background: var(--accent); color: #1a1512;
  font-size: 23px;
}
/* 소리를 기다리는 중 — 화면을 막지 않고 버튼만 조용히 숨쉰다 */
.ctl-main.buffering { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* ===== 스켈레톤 =====
   본문 글자는 이미 읽을 수 있으므로 가리지 않는다.
   소리를 기다리는 자리 — 번역줄과 반복 점 — 에만 대신 띄운다. */
.skeleton {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.sk-bar, .sk-dot {
  background: linear-gradient(90deg,
    var(--surface-2) 25%,
    rgba(224, 128, 92, .14) 50%,
    var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  border-radius: 4px;
}
.sk-ko { display: block; width: 62%; max-width: 260px; height: 14px; }
.sk-dots { display: flex; gap: 7px; }
.sk-dot { width: 7px; height: 7px; border-radius: 50%; }
.sk-dot:nth-child(2) { animation-delay: .12s; }
.sk-dot:nth-child(3) { animation-delay: .24s; }

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* 재생될 문장이 어디인지 본문에서도 옅게 알려 준다 */
.sent.current.loading {
  background: linear-gradient(90deg,
    var(--accent-soft) 25%,
    rgba(224, 128, 92, .32) 50%,
    var(--accent-soft) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}

/* 움직임에 민감한 사용자에게는 반짝임 대신 정적인 회색으로 */
@media (prefers-reduced-motion: reduce) {
  .sk-bar, .sk-dot, .sent.current.loading, .ctl-main.buffering {
    animation: none;
    background: var(--surface-2);
  }
  .sent.current.loading { background: var(--accent-soft); }
}
/* 반복·속도는 보조 컨트롤이라 작고 조용하게 */
.ctl-sm {
  width: 40px; height: 40px;
  background: none;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
}
.ctl-sm.on { color: var(--accent); }

.more-toggle {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  font-family: inherit;
  padding: 6px 0 10px;
  cursor: pointer;
}
.more-toggle:active { color: var(--text); }

.quick-settings { display: flex; gap: 10px; padding-bottom: 4px; }
.quick-settings label {
  flex: 1; display: flex; flex-direction: column; gap: 5px;
  font-size: 11px; color: var(--text-dim);
}
.quick-settings select {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--surface-2);
  border-radius: 10px; padding: 9px 8px; font-size: 14px;
}

.status-line {
  text-align: center; font-size: 12px; color: var(--text-dim);
  min-height: 16px; margin: 8px 0 0;
}

/* 조회 실패·건너뛴 책을 사용자에게 알리는 줄.
   실패를 조용히 삼키면 사용자는 "내 책이 지워졌다"고 오해한다. */
.shelf-notice {
  margin: 14px 16px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(208, 85, 63, .12);
  color: #e08a74;
  font-size: 12px;
  line-height: 1.5;
}

/* 오디오가 없거나 모자란 책 — 재생하고 나서 알면 늦다 */
.book-card-warn {
  margin: 3px 2px 0;
  font-size: 10px;
  color: #d0a03f;
}

.empty { text-align: center; color: var(--text-dim); padding: 40px 20px; }

/* 관리자로 넘어가는 링크 — 제작용이라 조용하게 둔다 */
.admin-link {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--surface-2);
  flex: none;
}
.admin-link:active { background: var(--surface-2); color: var(--text); }


/* ===== 이어읽기 물음 ===== */
.ask-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, .55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.ask-sheet {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: 16px;
  padding: 20px 18px 16px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .55);
}
.ask-title { margin: 0 0 6px; font-size: 17px; font-weight: 600; }
.ask-where { margin: 0 0 12px; font-size: 12px; color: var(--text-dim); }
/* 어디서 멈췄는지 문장으로 보여 준다. 쪽수만으로는 기억이 안 난다. */
.ask-preview {
  margin: 0 0 16px;
  padding: 11px 13px;
  border-radius: 10px;
  background: var(--bg);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ask-buttons { display: flex; gap: 9px; }
.ask-btn {
  flex: 1;
  padding: 13px 10px;
  border-radius: 11px;
  border: 1px solid var(--surface-2);
  background: none;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}
.ask-btn:active { background: var(--surface-2); }
.ask-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1512;
  font-weight: 600;
}

/* --- 당겨서 새로고침 --- */
.pull-refresh {
  position: fixed;
  top: 0; left: 50%;
  z-index: 40;
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  margin-left: -17px;
  border-radius: 50%;
  background: var(--surface-2);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
  /* translate 로만 움직인다 — top 을 건드리면 매 프레임 레이아웃이 다시 잡힌다 */
  transform: translateY(-56px);
  opacity: 0;
  pointer-events: none;
}
/* 손을 뗀 뒤에만 애니메이션을 건다. 끄는 중에 전환이 걸리면 손가락보다 늦게 따라온다. */
.pull-refresh.settling { transition: transform .22s ease, opacity .22s ease; }
.pull-spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--text-dim);
  border-top-color: transparent;
  border-radius: 50%;
}
.pull-refresh.spinning .pull-spinner { animation: pull-spin .7s linear infinite; }
@keyframes pull-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .pull-refresh.spinning .pull-spinner { animation-duration: 2s; }
}

/* 책을 여는 동안 — 본문을 받는 사이 아무 반응이 없으면 두 번 누르게 된다 */
.book-card.is-loading { opacity: .55; pointer-events: none; }

/* --- 학습 패널 --- */
.study-toggle {
  background: var(--surface-2); border: 1px solid transparent;
  color: var(--text-dim); font: inherit; font-size: 15px;
  padding: 5px 9px; border-radius: 9px; cursor: pointer; line-height: 1;
}
.study-toggle[aria-pressed="true"] {
  background: var(--accent-soft); border-color: rgba(224, 128, 92, .45); color: var(--accent);
}

.study-panel {
  flex: 1; min-height: 0; overflow-y: auto;
  margin: 0 12px;
  /* 마지막 줄이 재생바 뒤로 숨지 않게 아래를 넉넉히 둔다 */
  padding: 2px 0 28px;
  border-top: 1px solid #2a2523;
}
/* 패널이 열리면 본문은 자리를 내준다 — 둘 다 스크롤되면 어디를 밀지 헷갈린다 */
.study-open #page-body { flex: 0 0 auto; max-height: 32vh; overflow-y: auto; }
/* 문장 보기에서는 패널 맨 위 블록이 같은 문장을 이미 보여 준다.
   위아래로 두 번 나오면 화면만 먹으므로 접는다. '책으로 보기'는 쪽 전체가
   맥락이라 그대로 둔다. */
.study-open #sentence-body { display: none; }

.study-sec { margin-top: 18px; }
.study-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.study-tag {
  font-size: 12px; font-weight: 800; letter-spacing: .05em;
  color: var(--accent); background: var(--accent-soft);
  padding: 4px 9px; border-radius: 6px;
}
.study-note { font-size: 12.5px; color: var(--text-dim); }
.study-card { background: var(--surface); border-radius: 12px; padding: 14px 15px; }
.study-card + .study-card { margin-top: 8px; }

.sg-title { font-size: 17px; font-weight: 700; line-height: 1.5; }
.sg-body { margin-top: 8px; font-size: 15px; line-height: 1.85; color: #ded7cf; }
.sg-eg {
  margin-top: 12px; padding-top: 12px; border-top: 1px dashed #332d2a;
  font-size: 14.5px; color: var(--text-dim); line-height: 1.9;
}
.sg-eg b { color: #efe8e0; font-weight: 700; }

.sp-row { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; }
.sp-en { font-size: 17px; font-weight: 700; }
.sp-ko { font-size: 14.5px; color: var(--text-dim); }
.sp-note { margin-top: 7px; font-size: 14.5px; color: #d3cbc3; line-height: 1.8; }

.sw { display: flex; align-items: center; gap: 10px; }
.sw + .sw { margin-top: 12px; padding-top: 12px; border-top: 1px solid #241f1d; }
.sw-en { font-size: 17px; font-weight: 700; min-width: 92px; }
.sw-ko { flex: 1; font-size: 14.5px; line-height: 1.6; color: #d3cbc3; }
.sw-lv {
  font-size: 11px; font-weight: 800; padding: 3px 7px; border-radius: 5px;
  background: #2e2724; color: #b9afa6; letter-spacing: .03em;
}
.sw-lv.hard { background: rgba(216, 106, 84, .18); color: #e08b74; }

.study-msg { padding: 22px 4px; text-align: center; font-size: 13px; color: var(--text-dim); }

/* 학습 패널 맨 위 — 지금 풀어 주는 문장 */
.study-sent {
  margin-top: 14px;
  padding: 13px 15px;
  background: var(--accent-soft);
  border-radius: 12px;
  border-left: 3px solid var(--accent);
}
.ss-en { font-size: 16.5px; font-weight: 700; line-height: 1.55; }
.ss-ko { margin-top: 7px; font-size: 14.5px; line-height: 1.7; color: #d3cbc3; }

/* 어느 빌드인지 — 조용히, 그러나 확인은 되게 */
.build-stamp {
  margin: 6px 16px 18px;
  font-size: 11px;
  color: var(--text-dim);
  opacity: .5;
  text-align: center;
}

/* --- 서재 검색·거르기 --- */
.shelf-bar {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  padding: 10px 14px 8px;
  /* 안드로이드 15부터 edge-to-edge 가 강제라 앱이 상태 표시줄 밑까지 그려진다.
     이 줄이 없으면 검색창이 시계·배터리와 겹친다. 리더 화면(.top-bar)은
     이미 같은 처리를 하고 있었는데 서재만 빠져 있었다. */
  padding-top: calc(10px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--line, #2a2523);
}
.search-row { display: flex; align-items: center; gap: 8px; }
.search-icon { flex: none; color: var(--text-dim); }
#shelf-search {
  flex: 1; min-width: 0;
  background: var(--surface-2); border: 1px solid transparent;
  color: var(--text); font: inherit; font-size: 15px;
  padding: 10px 12px; border-radius: 10px;
  min-height: 44px;                 /* 손가락으로 누르는 크기 */
  -webkit-appearance: none;
}
#shelf-search:focus { outline: none; border-color: var(--accent); }
#shelf-search::placeholder { color: var(--text-dim); }
.clear-btn {
  flex: none; background: none; border: none; color: var(--text-dim);
  font: inherit; font-size: 15px; padding: 8px; cursor: pointer;
}

.filter-row {
  display: flex; gap: 7px; margin-top: 8px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.filter-row::-webkit-scrollbar { display: none; }
.filter-row select {
  flex: none;
  background: var(--surface-2); color: var(--text);
  border: 1px solid transparent; border-radius: 999px;
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 8px 30px 8px 13px; min-height: 36px;
  cursor: pointer; -webkit-appearance: none; appearance: none;
  /* 화살표는 배경 이미지로 — 기본 화살표는 안드로이드에서 제각각이다 */
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23a39a91' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.filter-row select.on {
  background-color: var(--accent-soft);
  border-color: rgba(224, 128, 92, .45);
  color: var(--accent);
}
.shelf-count { margin: 8px 2px 0; font-size: 12px; color: var(--text-dim); }
.shelf-empty { padding: 46px 20px; text-align: center; color: var(--text-dim); font-size: 14px; line-height: 1.7; }

/* ===== 공부 방식 서랍 ===== */
/* 자유공부와 문법공부는 성격이 다르다. 한 목록에 섞으면 문법 327섹션이
   이야기책을 덮어 버려서, 아예 갈라 놓고 여기서 고르게 한다. */
.menu-btn { flex: none; margin-right: 2px; }

.menu-scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, .55);
}

.menu-drawer {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 41;
  width: min(78vw, 300px);
  background: var(--surface);
  border-right: 1px solid var(--surface-2);
  padding: calc(18px + env(safe-area-inset-top)) 0 18px;
  /* 평소엔 화면 밖. transform 으로 밀어 GPU 에 맡긴다 — left 를 움직이면 끊긴다 */
  transform: translateX(-100%);
  transition: transform .22s ease;
}
.menu-drawer.is-open { transform: translateX(0); }
@media (prefers-reduced-motion: reduce) { .menu-drawer { transition: none; } }

.menu-head {
  margin: 0 0 10px; padding: 0 18px;
  font-size: 12px; letter-spacing: .06em;
  color: var(--text-dim);
}
.menu-item {
  display: block; width: 100%; text-align: left;
  padding: 13px 18px; border: 0; background: none;
  color: var(--text); font: inherit; cursor: pointer;
  border-left: 3px solid transparent;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item.is-active {
  border-left-color: var(--accent);
  background: var(--accent-soft);
}
.menu-item-title { display: block; font-size: 16px; font-weight: 600; }
.menu-item-desc {
  display: block; margin-top: 3px;
  font-size: 12.5px; color: var(--text-dim);
}

/* ===== 문법책 표지 ===== */
/* 이미지를 만들지 않는다. 문법에는 그릴 장면이 없어서 이미지 모델을 태우면
   327권이 전부 '혼란스러운 표정의 사람'으로 비슷해진다. 게다가 SVG 를 배경
   이미지로 쓰면 외부 폰트가 로딩되지 않아 Pretendard 가 안 먹는다.
   카드가 이미 HTML 이니 여기서 직접 조판하는 편이 정확하고 공짜다.

   크기는 cqw 가 아니라 px 로 못 박는다. 자유공부 카드가 쓰는 컨테이너 질의
   단위가 여기서는 카드 폭이 아닌 값으로 풀려서 글자가 7px 로 찌그러졌다.
   패턴 문자열은 우리가 정하므로 길이를 알고, 그러면 고정값이 더 안전하다. */
.book-card-cover.is-grammar {
  background: var(--accent);
  display: flex; flex-direction: column; justify-content: center;
  /* 좌측정렬. 자유공부의 가운데 정렬 후킹 타이포와 결을 다르게 둔다. */
  align-items: flex-start; text-align: left;
  padding: 0 20px;
  gap: 5px;
  /* 순번을 우측 상단에 띄우기 위한 기준점 */
  position: relative;
}
.book-card-cover.is-grammar .book-card-scrim,
.book-card-cover.is-grammar .book-card-title { display: none; }

/* 만든 순서(001·002…). 제목을 읽는 데 방해가 되면 안 되므로
   흐린 색에 작은 크기로 두고, 숫자 폭이 흔들리지 않게 고정폭 숫자를 쓴다. */
.gr-no {
  position: absolute; top: 12px; right: 14px;
  font-size: 12px; font-weight: 600; letter-spacing: .04em;
  color: rgba(28, 16, 6, .42);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* 영어 패턴은 보조. 어떤 문법인지 못 박아 주는 역할만 한다. */
.gr-pattern {
  font-size: 14px; font-weight: 500; line-height: 1.3;
  color: rgba(28, 16, 6, .66);
  /* 그림자·네온 없음. 배경이 단색이라 글자만으로 충분히 읽힌다. */
  word-break: keep-all;
}
/* 한국어가 주인공. 카드에서 제일 먼저 읽히는 자리다. */
.gr-label {
  font-size: 22px; font-weight: 700; line-height: 1.35;
  color: #1b1008;
  word-break: keep-all;
}
/* 카드가 넓어지는 화면에서는 조금 키운다 */
@media (min-width: 720px) {
  .book-card-cover.is-grammar { padding: 0 26px; gap: 7px; }
    .gr-label { font-size: 26px; }
  .gr-pattern { font-size: 15px; }
}
