/* ===== 페이퍼로지 (Paperlogy) — 눈누, SIL 오픈폰트라이선스(OFL)
   외부 CDN을 링크하지 않고 같은 폴더의 파일을 씁니다. 학교 방화벽에서도 뜹니다. ===== */
@font-face{
  font-family:"Paperlogy";
  src:url("../fonts/Paperlogy-4Regular.woff2") format("woff2");
  font-weight:400; font-style:normal; font-display:swap;
}
@font-face{
  font-family:"Paperlogy";
  src:url("../fonts/Paperlogy-7Bold.woff2") format("woff2");
  font-weight:700; font-style:normal; font-display:swap;
}

/* ===== 기본값 ===== */
*,*::before,*::after{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{
  margin:0;
  font-family:"Paperlogy","Pretendard","Apple SD Gothic Neo","Malgun Gothic",sans-serif;
  word-break:keep-all; overflow-wrap:break-word; line-break:strict;
  -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale;
  background:var(--bg); color:var(--ink);
  overscroll-behavior:none;
}
p,li,span,label,button,textarea,input,h1,h2,h3,h4{word-break:keep-all;overflow-wrap:break-word}
button{font:inherit;color:inherit;background:none;border:0;cursor:pointer}
/* 입력칸은 글꼴을 물려받지 않습니다. 직접 지정해야 페이퍼로지가 적용됩니다. */
textarea,input,select{font-family:inherit}
textarea{font-weight:400}
[hidden]{display:none!important}
:focus-visible{outline:3px solid var(--accent);outline-offset:2px;border-radius:6px}

/* ===== 색 ===== */
:root{
  --bg:#FBF7EE; --ink:#221F1A; --dim:#6B6558; --line:#E1D9C8; --card:#FFFDF8;
  --accent:#1E5F86; --accentSoft:#E6EFF5;
  --hl-y:#FFE9A3; --hl-g:#C9EFC2; --hl-b:#BFE0F5; --hl-p:#F7CFE0;
  --shadow:0 2px 10px rgba(60,50,30,.10);
  --fs:19.5px; --lh:1.95;
  /* 블록 스타일: 굵은 테두리 + 번지지 않는 그림자 + 격자 종이 */
  --edge:#16150F;            /* 테두리·그림자 색 */
  --grid:rgba(22,21,15,.07); /* 격자 선 */
  --pill:#FFD3E4;            /* 분홍 알약 라벨 */
  --r:16px;                  /* 블록 모서리 */
  --brandH:clamp(38px,4.3vw,56px);  /* 맨 윗줄(제목 알약·로고) 높이 */
}
body[data-theme="white"]{--bg:#FFFFFF;--ink:#1A1A1A;--dim:#6A6A6A;--line:#E8E8E8;--card:#FFFFFF;--grid:rgba(20,20,20,.06)}
body[data-theme="sepia"]{--bg:#F1E4CE;--ink:#3A2E1E;--dim:#7A6A52;--line:#DFCDAE;--card:#F6ECDB;--edge:#3A2E1E;--grid:rgba(58,46,30,.08);--pill:#F4C4D8}
body[data-theme="dark"]{
  --bg:#17181A;--ink:#E4E2DD;--dim:#9A968E;--line:#2E3034;--card:#1E2023;
  --accent:#79B8DE;--accentSoft:#22303A;
  --hl-y:#6A5B22;--hl-g:#2F5730;--hl-b:#284A63;--hl-p:#5C2F45;
  --shadow:0 2px 10px rgba(0,0,0,.45);
  /* 어두운 화면에서는 테두리와 그림자가 밝은 쪽으로 뒤집힙니다 */
  --edge:#E7E3D8; --grid:rgba(231,227,216,.07); --pill:#8A4463;
}

/* ===== 화면 전환 ===== */
.screen{display:none;min-height:100dvh}
.screen.on{display:block}
.screen#scr-read.on{display:flex;flex-direction:column;height:100dvh;overflow:hidden}

/* ══════════ 서재 ══════════ */
/* 첨부 시안대로: 격자 종이 위에 굵은 검정 테두리 블록,
   번지지 않는(blur 0) 오프셋 그림자, 분홍 알약 라벨. */

#scr-home{
  position:relative;
  background-color:var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size:24px 24px;
}
.home{
  max-width:1120px;margin:0 auto;
  padding:calc(var(--brandH) + clamp(30px,4vw,52px)) clamp(16px,3vw,24px) 80px;
}

/* 공통 블록 */
.blk{
  background:var(--card);
  border:3px solid var(--edge);
  border-radius:var(--r);
  box-shadow:6px 6px 0 0 var(--edge);
}
.press{transition:transform .12s cubic-bezier(.2,0,0,1), box-shadow .12s cubic-bezier(.2,0,0,1)}
.press:hover{transform:translate(3px,3px);box-shadow:3px 3px 0 0 var(--edge)}
.press:active{transform:translate(6px,6px);box-shadow:0 0 0 0 var(--edge)}

/* 머리 블록 */
.hero{padding:clamp(22px,3.4vw,32px) clamp(20px,3.4vw,34px) clamp(24px,3.4vw,32px);margin-bottom:clamp(20px,3vw,30px)}

/* 서재 이름표 — 흰 알약에 두클래스만 로고 민트. 이 화면에서 가장 큰 글씨입니다. */
.pill{
  background:#FFFFFF;color:#16150F;
  border:3px solid #16150F;border-radius:99px;
  box-shadow:5px 5px 0 0 #16150F;
  height:var(--brandH);
  display:inline-flex;align-items:center;gap:.3em;flex:none;
  padding:0 clamp(16px,2.2vw,30px);
  font-size:clamp(1.02rem,.72rem + 1.05vw,1.55rem);
  font-weight:700;letter-spacing:.01em;line-height:1;
  white-space:nowrap;
}
body[data-theme="dark"] .pill{
  background:#22242A;color:#F4F0E6;border-color:#F4F0E6;box-shadow:5px 5px 0 0 #F4F0E6;
}
.pill__brand{color:#12A98D;font-weight:inherit}
.hero__sub{margin:0;color:var(--dim);font-size:1.02rem;line-height:1.7}
.hero__sub b{color:var(--ink)}

/* 미션 진행 막대 — 시안의 가는 테두리 막대 */
.homeMission{margin:18px 0 0}
.homeMission .progressbar{
  height:16px;border:2.5px solid var(--edge);border-radius:99px;
  background:var(--bg);overflow:hidden;margin:0;padding:0;
}
.homeMission .progressbar i{background:var(--pill);border-radius:0}
.homeMission .drawer__cnt{text-align:left;margin:8px 2px 0;font-size:.9rem}


/* 책장 */
.shelf{display:grid;gap:clamp(18px,2.4vw,24px);grid-template-columns:1fr}
@media(min-width:720px){.shelf{grid-template-columns:1fr 1fr}}
@media(min-width:1060px){.shelf{grid-template-columns:1fr 1fr 1fr}}
.shelf>*{min-width:0}

.card{
  display:flex;flex-direction:column;overflow:hidden;
  background:var(--card);border:3px solid var(--edge);border-radius:var(--r);
  box-shadow:6px 6px 0 0 var(--edge);
}
/* 표지 — 밝은 파스텔. 글씨는 늘 진한 잉크색이라 어느 색 위에서도 또렷합니다. */
.card__cover{
  position:relative;padding:24px 20px 20px;min-height:186px;
  display:flex;flex-direction:column;
  color:#16150F;
  border-bottom:3px solid var(--edge);
  background:var(--cv, #C9E3F7);
}
.card[data-tint="sky"]     .card__cover{--cv:#C9E3F7}
.card[data-tint="lemon"]   .card__cover{--cv:#F7EDA8}
.card[data-tint="mint"]    .card__cover{--cv:#C6E9CE}
.card[data-tint="coral"]   .card__cover{--cv:#FBD1C6}
.card[data-tint="rose"]    .card__cover{--cv:#F8CFE3}
.card[data-tint="lilac"]   .card__cover{--cv:#DDD3F7}
.card[data-tint="teal"]    .card__cover{--cv:#BFE6E3}

/* 검은색 배경일 때는 표지를 한 겹 눌러 주고 글씨를 밝게 뒤집습니다 */
body[data-theme="dark"] .card__cover{color:#F0EDE5}
body[data-theme="dark"] .card__cover::after{
  content:"";position:absolute;inset:0;background:rgba(12,12,16,.66);pointer-events:none
}
body[data-theme="dark"] .card__cover > *{position:relative;z-index:1}

.card__kind{
  align-self:flex-start;background:#FFFFFF;color:#16150F;
  border:2.5px solid #16150F;border-radius:99px;padding:4px 13px;
  font-size:.82rem;font-weight:700;letter-spacing:.02em;
}
body[data-theme="dark"] .card__kind{background:#1E2023;color:#F0EDE5;border-color:#F0EDE5}
.card__rule{display:block;width:46px;height:3px;background:currentColor;opacity:.5;margin:14px 0 auto}
.card__cover h3{font-size:1.5rem;line-height:1.32;margin:0;text-wrap:balance}
.card__sub{margin:6px 0 0;font-size:.95rem;opacity:.8;line-height:1.5}
.card__by{margin:12px 0 0;font-size:.86rem;opacity:.62}
.card__stamp{
  position:absolute;top:18px;right:16px;font-size:.84rem;font-weight:700;
  background:#16150F;color:#F7F3E9;
  border:2.5px solid #16150F;border-radius:99px;padding:4px 12px;
}
body[data-theme="dark"] .card__stamp{background:#F0EDE5;color:#16150F;border-color:#F0EDE5}
.card__body{padding:18px 20px 20px;display:flex;flex-direction:column;gap:11px;flex:1}
.card__blurb{margin:0;font-size:.96rem;line-height:1.72;color:var(--dim);flex:1;text-wrap:pretty}
.card__meta{margin:0;font-size:.88rem;color:var(--dim)}
.card__bar{height:12px;border:2.5px solid var(--edge);border-radius:99px;background:var(--bg);overflow:hidden}
.card__bar i{display:block;height:100%;background:var(--pill)}
.card__acts{display:flex;flex-wrap:wrap;gap:9px;align-items:center;margin-top:3px}

/* 내 기록 지우기 — 테두리 없이 단추만 오른쪽에 */
.strip{display:flex;justify-content:flex-end;margin-top:clamp(18px,2.4vw,26px)}

/* 단추 — 같은 블록 언어 */
.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:8px;
  padding:11px 20px;border-radius:12px;
  background:#FFE04D;color:#16150F;
  border:2.5px solid var(--edge);
  box-shadow:4px 4px 0 0 var(--edge);
  font-size:1rem;font-weight:700;
  transition:transform .12s cubic-bezier(.2,0,0,1), box-shadow .12s cubic-bezier(.2,0,0,1);
}
.btn:hover{transform:translate(2px,2px);box-shadow:2px 2px 0 0 var(--edge)}
.btn:active{transform:translate(4px,4px);box-shadow:0 0 0 0 var(--edge)}
.btn--ghost{background:var(--card);color:var(--ink)}
body[data-theme="dark"] .btn{border-color:#16150F}
body[data-theme="dark"] .btn--ghost{border-color:var(--edge)}
.btn--text{background:var(--bg);color:var(--dim);font-weight:400}
.btn--sm{padding:9px 15px;font-size:.94rem}

/* ══════════ 브랜드 · 미션 · 잠긴 책장 ══════════ */
/* 화면 맨 윗줄 — 왼쪽 제목 알약, 오른쪽 로고. 둘의 높이를 --brandH로 맞춥니다. */
.brandrow{
  position:absolute;z-index:40;
  top:clamp(10px,1.5vw,16px);
  left:clamp(12px,2vw,20px);
  right:clamp(12px,2vw,20px);
  display:flex;align-items:center;justify-content:space-between;gap:12px;
}
.brandmark{height:var(--brandH);width:auto;flex:none;pointer-events:none}
body[data-theme="dark"] .brandmark{
  /* 어두운 배경에서도 또렷하도록 밝은 판을 깔아 줍니다 */
  background:rgba(255,255,255,.92);border-radius:10px;padding:4px 6px;
}
.home__top{margin-bottom:clamp(18px,3vw,26px)}
/* ===== 전광판 안내 ===== */
.sronly{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
.ticker{
  overflow:hidden;
  background:#16150F;color:#FBF7EE;
  border:3px solid var(--edge);border-radius:var(--r);
  box-shadow:6px 6px 0 0 var(--edge);
  height:clamp(48px,5.6vw,60px);display:flex;align-items:center;
}
.ticker__track{display:flex;flex:none;animation:tick 38s linear infinite}
.ticker:hover .ticker__track{animation-play-state:paused}
.ticker__row{display:flex;flex:none;align-items:center;white-space:nowrap}
.ticker em{font-style:normal;font-size:clamp(.98rem,.86rem + .5vw,1.18rem);letter-spacing:.01em}
.ticker b{font-weight:700;color:#7FE3CC}
.ticker i{font-style:normal;color:#7FE3CC;opacity:.55;padding:0 1.15em;font-size:.7em}
@keyframes tick{from{transform:translateX(0)}to{transform:translateX(-50%)}}
@media (prefers-reduced-motion:reduce){
  .ticker__track{animation:none}
  .ticker{overflow:auto}
}

.home__top h1{
  font-size:clamp(1.08rem,.95rem + .7vw,1.34rem);line-height:1.5;
  margin:0;color:var(--dim);font-weight:400;text-wrap:balance;
}

/* 1단계·2단계 블록. 안쪽 여백이 같아서 두 배지가 세로로 나란히 놓입니다. */
.course,
.stage2{
  display:flex;flex-wrap:wrap;align-items:center;gap:clamp(14px,2.4vw,22px);
  padding:clamp(18px,2.6vw,24px) clamp(18px,2.8vw,26px);
  margin-bottom:clamp(20px,2.8vw,28px);
}
/* 단계 배지 — 연한 크림색 그림자 블록 */
.course__no{
  flex:none;
  background:#FBF0DA;color:#16150F;
  border:2.5px solid #16150F;border-radius:99px;
  box-shadow:3px 3px 0 0 #16150F;
  padding:6px 17px;font-size:.94rem;font-weight:700;
}
body[data-theme="dark"] .course__no{
  background:#3C3729;color:#F4F0E6;border-color:#F4F0E6;box-shadow:3px 3px 0 0 #F4F0E6;
}
.course__main{flex:1;min-width:210px}
.course__main h2{margin:0 0 4px;font-size:1.24rem}
.course__main p{margin:0;color:var(--dim);font-size:.96rem;line-height:1.6;text-wrap:balance}
.course__bar{
  height:14px;border:2.5px solid var(--edge);border-radius:99px;
  background:var(--bg);overflow:hidden;margin:12px 0 6px;
}
.course__bar i{display:block;height:100%;background:var(--pill);transition:width .3s}
.course.cleared .course__bar i{background:#93DCAC}
.course__cnt{margin:0;font-size:.88rem;color:var(--dim)}

.linkbtn{color:var(--accent);text-decoration:underline;text-underline-offset:3px;font-size:.94rem;padding:0}

.card{position:relative}
.shelf.locked .card{opacity:.45;filter:saturate(.45)}

/* ══════════ 미션 퀘스트 팝업 ══════════ */
/* 화면 아래 가운데에 크게 띄웁니다. 읽으면서 따라 할 안내라 글씨를 키웠습니다. */
.quest{
  position:fixed;left:50%;transform:translateX(-50%);bottom:58px;z-index:100;display:none;
  width:min(660px, calc(100vw - 28px));
  background:var(--card);border:3px solid var(--edge);border-radius:var(--r);
  box-shadow:6px 6px 0 0 var(--edge);overflow:hidden;text-align:center;
}
.quest.on{display:block}
.quest__top{
  display:flex;align-items:center;gap:12px;padding:11px 12px 11px 18px;
  background:var(--pill);border-bottom:3px solid var(--edge);
}
.quest__step{flex:none;font-size:.98rem;font-weight:700;color:var(--edge)}
.quest__bar{
  flex:1;height:12px;border:2px solid var(--edge);border-radius:99px;
  background:var(--card);overflow:hidden;
}
.quest__bar i{display:block;height:100%;background:var(--edge);transition:width .3s}
.quest__fold{flex:none;width:30px;height:30px;display:grid;place-items:center;color:var(--edge);border-radius:7px}
.quest__fold svg{
  width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:2.4;
  stroke-linecap:round;stroke-linejoin:round;transition:transform .15s;
}
.quest.folded .quest__fold svg{transform:rotate(180deg)}
.quest.folded .quest__body{display:none}

.quest__body{padding:20px clamp(18px,3vw,28px) 20px}
/* text-wrap:balance 가 줄 길이를 스스로 고르게 나눕니다.
   마지막 줄에 낱말 하나만 남는 일을 막아 줍니다. */
.quest__ask{
  margin:0 auto;max-width:34em;
  font-size:clamp(1.1rem,1rem + .4vw,1.3rem);line-height:1.68;
  text-wrap:balance;
}
/* 칭찬 뒤에 붙는 설명은 길어서 균등 배분 대신 예쁘게 흘립니다 */
.quest.cleared .quest__ask{max-width:34em;text-wrap:pretty}
/* 문장 한 덩어리. 줄바꿈이 문장이 끝나는 자리에서 일어나게 합니다. */
.sn{display:inline-block}
/* 형광 강조는 한 덩어리로 붙여 둡니다. 줄 끝에서 쪼개지면 보기 나쁩니다.
   balance 가 나머지 줄 길이를 맞춰 주므로 빈틈이 생기지 않습니다. */
.quest__ask b{
  background:var(--hl-y);border-radius:4px;padding:1px 5px;
  white-space:nowrap;
}
.quest__yes{
  display:block;font-weight:700;color:#1B7A4A;
  margin-bottom:8px;font-size:clamp(1.24rem,1.1rem + .5vw,1.48rem);
  text-wrap:balance;
}
body[data-theme="dark"] .quest__yes{color:#7BD3A0}

/* 힌트는 한 겹 더 안쪽 블록에 넣습니다 */
.quest__hint{
  margin:14px auto 0;max-width:33em;
  background:var(--accentSoft);border:2.5px solid var(--edge);border-radius:12px;
  padding:11px 16px;font-size:1.01rem;line-height:1.68;color:var(--ink);
  text-wrap:balance;
}
.quest__acts{display:flex;flex-wrap:wrap;gap:10px;align-items:center;justify-content:center;margin-top:18px}
.quest__acts .btn{font-size:1.02rem;padding:11px 22px}

.quest.cleared .quest__top{background:#BFEBD0}
body[data-theme="dark"] .quest.cleared .quest__top{background:#2C5E42}

@media(max-width:700px){
  .quest{left:8px;right:8px;transform:none;bottom:52px;width:auto}
  .quest__body{padding:16px 15px}
  .quest__ask{font-size:1.06rem}
  .quest__hint{font-size:.96rem}
}
.mission.now{background:var(--accentSoft);border-radius:8px}

/* 지금 눌러야 할 단추를 맥박처럼 짚어 줍니다 */
@keyframes pointpulse{
  0%  {box-shadow:0 0 0 0 rgba(233,74,140,.55)}
  70% {box-shadow:0 0 0 11px rgba(233,74,140,0)}
  100%{box-shadow:0 0 0 0 rgba(233,74,140,0)}
}
.pointme{
  position:relative;z-index:1;border-radius:10px;
  animation:pointpulse 1.5s cubic-bezier(.2,0,0,1) infinite;
  outline:2.5px solid #E94A8C;outline-offset:1px;
}
.pointme.seltool__colors{border-radius:12px}
@media (prefers-reduced-motion:reduce){
  .pointme{animation:none}
}

/* ══════════ 쪽수로 바로 가기 ══════════ */
.pagego{flex:none;display:inline-flex;align-items:center;gap:5px;font-size:.86rem;color:var(--dim)}
.pagego input{
  width:52px;padding:5px 6px;text-align:center;font:inherit;font-size:.9rem;
  border:2.5px solid var(--edge);border-radius:9px;background:var(--bg);color:var(--ink);
}
.pagego input:focus{outline:none;box-shadow:2.5px 2.5px 0 0 var(--edge)}
.pagego input::-webkit-outer-spin-button,
.pagego input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}
.pagego input[type=number]{-moz-appearance:textfield}
.pagego b{color:var(--ink)}
.pagego__btn{
  width:30px;height:28px;display:grid;place-items:center;
  border:2.5px solid var(--edge);border-radius:9px;background:var(--bg);color:var(--edge);
  box-shadow:2.5px 2.5px 0 0 var(--edge);
  transition:transform .12s cubic-bezier(.2,0,0,1), box-shadow .12s cubic-bezier(.2,0,0,1), background .12s;
}
.pagego__btn:hover{background:var(--pill)}
.pagego__btn:active{transform:translate(2.5px,2.5px);box-shadow:0 0 0 0 var(--edge)}
.pagego__btn svg{
  width:15px;height:15px;fill:none;stroke:currentColor;stroke-width:2.4;
  stroke-linecap:round;stroke-linejoin:round;
}
@media(max-width:820px){.foot__chap{display:none}}

/* ══════════ 팝업 안내문 ══════════ */
.modal__msg{margin:0 0 4px;font-size:1rem;line-height:1.75;color:var(--ink);text-wrap:balance}
.modal__box{border-radius:var(--r)}

/* ══════════ 푸터 ══════════ */
.credit{
  display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:.4rem;
  margin-top:clamp(18px,2.6vw,26px);padding:10px 8px 0;
  font-size:.86rem;color:var(--dim);
}
.credit .dot{width:3px;height:3px;border-radius:50%;background:var(--dim);opacity:.55;flex:none}
.credit a{font-weight:700;text-decoration:none}
.credit a:hover{opacity:.72}
.credit a.c-dou{color:#159C79}
.credit a.c-gga{color:#2E6DB4}
body[data-theme="dark"] .credit a.c-dou{color:#4FD3AE}
body[data-theme="dark"] .credit a.c-gga{color:#79ADE8}

/* ══════════ 뷰어 ══════════ */
.bar{
  flex:none;display:flex;align-items:center;gap:2px;padding:0 6px;height:52px;
  border-bottom:1px solid var(--line);background:var(--card);position:relative;z-index:30
}
.bar__title{flex:1;min-width:0;text-align:center;font-size:.95rem;color:var(--dim);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding:0 6px}
.ic{
  flex:none;width:44px;height:44px;display:grid;place-items:center;border-radius:10px;
  color:var(--ink);transition:background .15s
}
.ic:hover{background:var(--accentSoft)}
.ic[aria-pressed="true"]{color:var(--accent)}
.ic svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}
.ic--on svg{fill:currentColor;stroke:currentColor}
.ic--aa{font-weight:700;line-height:1}
.ic--aa span:first-child{font-size:1.04rem}
.ic--aa span:last-child{font-size:.76rem}

/* 본문: CSS 다단으로 잘라 옆으로 미는 방식 — 실제 전자책 뷰어와 같은 원리 */
.stage{flex:1;position:relative;overflow:hidden;min-height:0}
.viewport{
  position:absolute;top:0;bottom:0;overflow:hidden;
  /* 본문 한 줄이 너무 길어지지 않도록 최대 폭을 760px로 잡고 가운데에 둡니다.
     한글 본문은 한 줄 35~40자일 때 가장 읽기 좋습니다.
     폭을 padding이 아니라 left/right로 잡아야 옆 단이 새어 나오지 않습니다. */
  left:max(clamp(18px,4.5vw,64px), calc((100% - var(--maxw,760px)) / 2));
  right:max(clamp(18px,4.5vw,64px), calc((100% - var(--maxw,760px)) / 2));
  padding:clamp(18px,3.2vw,40px) 0;
}
/* 미션 팝업이 떠 있는 동안에는 본문이 그 위까지만 흐르게 합니다 */
.stage.quest-on .viewport{bottom:var(--questH,0px)}
.paper{
  height:100%;
  column-fill:auto;
  transition:transform .28s cubic-bezier(.25,.8,.35,1);
  will-change:transform;
}
.paper h2{
  font-size:1.3em;line-height:1.45;margin:0 0 .9em;padding-bottom:.5em;
  border-bottom:1.5px solid var(--line);
  break-before:column;break-after:avoid-column;text-wrap:balance
}
.paper h2:first-child{break-before:auto}
.paper p{
  font-size:var(--fs);line-height:var(--lh);margin:0;
  text-indent:1em;            /* 문단 첫 줄 들여쓰기 — 종이책과 같은 방식 */
  text-align:justify;         /* 양쪽 맞춤 */
  text-wrap:pretty;break-inside:auto
}
.paper.ragged p{text-align:left}
.paper p:first-of-type,.paper h2+p{text-indent:0}  /* 장 첫 문단은 들여쓰지 않음 */
.paper p.sep{
  text-indent:0;text-align:center;color:var(--dim);
  margin:.9em 0;letter-spacing:.5em
}
.paper p.box{
  text-indent:0;text-align:left;
  border:1.5px solid var(--line);border-radius:10px;
  background:var(--accentSoft);
  padding:.7em .9em;margin:.7em 0;
  font-size:calc(var(--fs) * .94);line-height:1.75;
  break-inside:avoid
}
.paper p.box+p{text-indent:1em}
.paper mark{background:var(--hlc,var(--hl-y));color:inherit;padding:.06em 0;border-radius:2px}
.paper mark.has-memo{box-shadow:inset 0 -2px 0 var(--accent)}
.paper p.flash{background:var(--accentSoft);border-radius:4px;box-shadow:0 0 0 5px var(--accentSoft);transition:background .3s}

/* 좌우 넘김 영역 */
.tapzone{position:absolute;top:0;bottom:0;width:clamp(34px,5.5vw,74px);z-index:5}
.tapzone--l{left:0}.tapzone--r{right:0}

.foot{
  flex:none;height:56px;display:flex;align-items:center;gap:12px;
  padding:0 16px;border-top:3px solid var(--edge);background:var(--card);font-size:.86rem;color:var(--dim)
}
.navbtn{
  flex:none;display:inline-flex;align-items:center;gap:5px;
  height:32px;padding:0 12px;font-size:.9rem;font-weight:700;
  color:var(--edge);background:var(--bg);
  border:2.5px solid var(--edge);border-radius:10px;
  box-shadow:3px 3px 0 0 var(--edge);
  transition:transform .12s cubic-bezier(.2,0,0,1), box-shadow .12s cubic-bezier(.2,0,0,1), background .12s;
}
.navbtn:hover{background:var(--pill)}
.navbtn:active{transform:translate(3px,3px);box-shadow:0 0 0 0 var(--edge)}
.navbtn:disabled{opacity:.4;box-shadow:none;transform:none}
.navbtn svg{
  width:15px;height:15px;flex:none;fill:none;stroke:currentColor;stroke-width:2.6;
  stroke-linecap:round;stroke-linejoin:round;
}
.foot__chap{flex:none;max-width:40%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.foot input[type=range]{flex:1;min-width:0;accent-color:var(--accent);height:22px}
.foot__pct{flex:none;font-variant-numeric:tabular-nums}

/* ===== 문장 선택 도구 ===== */
.seltool{
  position:absolute;z-index:60;display:none;background:var(--card);border:1px solid var(--line);
  border-radius:14px;box-shadow:0 8px 26px rgba(0,0,0,.22);padding:8px;gap:6px;
  flex-direction:column;min-width:250px
}
.seltool.on{display:flex}
.seltool__colors{display:flex;gap:8px;justify-content:center;padding:2px}
.swatch{width:34px;height:34px;border-radius:50%;border:2px solid rgba(0,0,0,.10)}
.swatch[data-c=y]{background:var(--hl-y)}.swatch[data-c=g]{background:var(--hl-g)}
.swatch[data-c=b]{background:var(--hl-b)}.swatch[data-c=p]{background:var(--hl-p)}
.seltool__acts{display:flex;gap:4px;border-top:1px solid var(--line);padding-top:6px}
.seltool__acts button{
  flex:1;display:flex;flex-direction:column;align-items:center;gap:3px;
  padding:7px 4px;border-radius:9px;font-size:.84rem;color:var(--dim)
}
.seltool__acts button:hover{background:var(--accentSoft);color:var(--accent)}
.seltool__acts svg{width:19px;height:19px;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}

/* ===== 오른쪽 서랍 ===== */
.scrim{position:fixed;inset:0;background:rgba(20,18,14,.42);z-index:70;opacity:0;pointer-events:none;transition:opacity .22s}
.scrim.on{opacity:1;pointer-events:auto}
.drawer{
  position:fixed;top:0;right:0;bottom:0;width:min(420px,90vw);background:var(--bg);
  z-index:80;transform:translateX(101%);transition:transform .26s cubic-bezier(.25,.8,.35,1);
  display:flex;flex-direction:column;border-left:3px solid var(--edge);
}
.drawer.on{transform:none}
.drawer__tabs{
  flex:none;display:flex;gap:8px;padding:14px 52px 12px 16px;
  background:var(--card);border-bottom:3px solid var(--edge);
}
.drawer__tabs button{
  flex:1;padding:9px 4px;font-size:.94rem;font-weight:700;color:var(--edge);
  background:var(--card);border:2.5px solid var(--edge);border-radius:99px;
  transition:transform .12s cubic-bezier(.2,0,0,1), box-shadow .12s cubic-bezier(.2,0,0,1);
}
.drawer__tabs button[aria-selected=true]{
  background:var(--pill);box-shadow:3px 3px 0 0 var(--edge);
}
.drawer__body{flex:1;overflow:auto;padding:16px 16px 34px;-webkit-overflow-scrolling:touch}
.drawer__close{position:absolute;top:12px;right:10px;z-index:1}
.drawer__h{margin:22px 0 10px;font-size:.9rem;color:var(--dim);font-weight:400}
.drawer__cnt{text-align:center;font-size:.94rem;color:var(--dim);margin:0 0 14px}
.drawer__cnt b{color:var(--ink)}

.toc button{
  display:block;width:100%;text-align:left;margin-bottom:8px;
  padding:13px 15px;font-size:1rem;line-height:1.5;
  background:var(--card);border:2.5px solid var(--edge);border-radius:12px;
  transition:transform .12s cubic-bezier(.2,0,0,1), box-shadow .12s cubic-bezier(.2,0,0,1);
}
.toc button:hover{transform:translate(2px,2px);box-shadow:0 0 0 0 var(--edge)}
.toc button.cur{background:var(--pill);box-shadow:3px 3px 0 0 var(--edge)}
.toc small{display:block;color:var(--dim);font-size:.84rem;margin-top:3px;font-weight:400}

.rec{
  background:var(--card);border:2.5px solid var(--edge);border-radius:12px;
  box-shadow:3px 3px 0 0 var(--edge);
  padding:13px 15px;margin-bottom:12px;
}
.rec__q{font-size:.95rem;line-height:1.6;margin:0 0 6px;padding-left:10px;border-left:5px solid var(--hlc,var(--hl-y))}
.rec__memo{
  font-size:.9rem;background:var(--accentSoft);border:2px solid var(--edge);
  border-radius:9px;padding:8px 11px;margin:9px 0 0;line-height:1.6;
}
.rec__foot{display:flex;align-items:center;gap:8px;margin-top:10px;font-size:.84rem;color:var(--dim)}
.rec__foot button{
  margin-left:auto;color:var(--edge);font-size:.84rem;font-weight:700;
  padding:5px 10px;border:2px solid var(--edge);border-radius:8px;background:var(--bg);
}
.rec__foot button:hover{background:var(--pill)}
.rec__foot button+button{margin-left:0}
.empty{color:var(--dim);font-size:.94rem;text-align:center;padding:38px 10px;line-height:1.8}

/* 미션 목록 — 하나씩 블록으로 */
.mission{
  display:flex;gap:12px;align-items:center;
  background:var(--card);border:2.5px solid var(--edge);border-radius:12px;
  padding:12px 14px;margin-bottom:9px;
}
.mission__box{
  flex:none;width:26px;height:26px;border-radius:8px;
  border:2.5px solid var(--edge);background:var(--bg);
  display:grid;place-items:center;color:transparent;font-size:.9rem;font-weight:700;
}
.mission.done{background:var(--pill)}
.mission.done .mission__box{background:var(--edge);border-color:var(--edge);color:var(--card)}
.mission.done .mission__t{text-decoration:none}
.mission.now{box-shadow:3px 3px 0 0 var(--edge);background:var(--card)}
.mission.now .mission__box{background:#FFE04D}
.mission__t{font-size:.99rem;line-height:1.45;font-weight:700}
.mission__h{display:block;font-size:.86rem;color:var(--dim);font-style:normal;font-weight:400;margin-top:2px}
.stepttl{font-size:.88rem;color:var(--dim);font-weight:700;margin:18px 0 8px;padding-left:4px}
.stepttl:first-child{margin-top:2px}
.progressbar{
  height:14px;border:2.5px solid var(--edge);border-radius:99px;
  background:var(--bg);overflow:hidden;margin:2px 0 10px;
}
.progressbar i{display:block;height:100%;background:var(--pill);transition:width .3s}

/* ===== 읽기 설정 시트 ===== */
.sheet{
  position:absolute;top:56px;right:8px;z-index:90;width:min(330px,92vw);background:var(--card);
  border:1px solid var(--line);border-radius:16px;box-shadow:0 10px 30px rgba(0,0,0,.2);
  padding:16px;display:none
}
.sheet.on{display:block}
.sheet--narrow{width:min(272px,92vw)}
.sheet h4{margin:0 0 9px;font-size:.88rem;color:var(--dim);font-weight:400}
.sheet section+section{margin-top:16px}
.seg{display:flex;gap:6px}
.seg button{
  flex:1;padding:11px 6px;border-radius:10px;border:1.5px solid var(--line);
  font-size:.92rem;color:var(--dim);background:var(--bg)
}
.seg button[aria-pressed=true]{border-color:var(--accent);color:var(--accent);background:var(--accentSoft);font-weight:700}
.seg--theme button{height:44px;font-size:.84rem}
.seg--theme button[data-t=white]{background:#fff;color:#333}
.seg--theme button[data-t=paper]{background:#FBF7EE;color:#333}
.seg--theme button[data-t=sepia]{background:#F1E4CE;color:#3A2E1E}
.seg--theme button[data-t=dark]{background:#17181A;color:#E4E2DD}

/* ===== 검색 ===== */
.search{position:absolute;top:0;left:0;right:0;z-index:95;background:var(--card);
  border-bottom:1px solid var(--line);padding:8px;display:none;gap:8px;align-items:center}
.search.on{display:flex}
.search input{flex:1;min-width:0;padding:11px 14px;font-size:1rem;border:1.5px solid var(--line);
  border-radius:10px;background:var(--bg);color:var(--ink)}
.sresults{position:absolute;top:100%;left:0;right:0;max-height:56vh;overflow:auto;background:var(--card);
  border-bottom:1px solid var(--line);box-shadow:var(--shadow)}
.sresults button{display:block;width:100%;text-align:left;padding:13px 16px;border-bottom:1px solid var(--line);font-size:.94rem;line-height:1.6}
.sresults button:hover{background:var(--accentSoft)}
.sresults button[disabled]{cursor:default;color:var(--dim)}
.sresults b{background:var(--hl-y);color:#221F1A;border-radius:2px;padding:0 1px}
.sresults small{display:block;color:var(--dim);font-size:.84rem;margin-bottom:3px}

/* ===== 메모 입력 ===== */
.modal{position:fixed;inset:0;z-index:120;display:none;align-items:center;justify-content:center;padding:20px;
  background:rgba(20,18,14,.5)}
.modal.on{display:flex}
.modal__box{background:var(--card);border-radius:16px;padding:20px;width:min(520px,100%);box-shadow:0 14px 40px rgba(0,0,0,.3)}
.modal__box h3{margin:0 0 10px;font-size:1.05rem}
.modal__q{font-size:.94rem;line-height:1.65;color:var(--dim);border-left:4px solid var(--hl-y);
  padding-left:11px;margin:0 0 14px;max-height:7.5em;overflow:auto}
.modal__box textarea{
  width:100%;min-height:120px;padding:13px 15px;font-size:1.02rem;line-height:1.75;
  border:2.5px solid var(--edge);border-radius:11px;background:var(--bg);color:var(--ink);resize:vertical
}
.modal__acts{display:flex;gap:8px;justify-content:flex-end;margin-top:14px}
#nameInput{
  width:100%;margin-top:12px;padding:13px 15px;font-size:1.05rem;
  border:2.5px solid var(--edge);border-radius:11px;
  background:var(--bg);color:var(--ink);
}
#nameInput:focus{outline:none;box-shadow:3px 3px 0 0 var(--edge)}

/* ===== 독후활동 노트 ===== */
#scr-note{
  background-color:var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size:24px 24px;
}
.note{max-width:860px;margin:0 auto;padding:clamp(20px,4vw,44px) clamp(16px,3vw,24px) 80px}
.note__top{display:flex;align-items:center;gap:10px;margin-bottom:clamp(20px,3vw,28px);flex-wrap:wrap}
.note__ttl{flex:1;min-width:180px}
.note__ttl h2{font-size:clamp(1.34rem,1.1rem + 1vw,1.7rem);margin:0}
.note__ttl p{margin:2px 0 0;font-size:.92rem;color:var(--dim)}

.qcard{
  background:var(--card);
  border:3px solid var(--edge);border-radius:var(--r);
  box-shadow:6px 6px 0 0 var(--edge);
  padding:20px 22px 22px;margin-bottom:clamp(18px,2.4vw,24px);
}
.qcard h3{
  display:inline-block;margin:0 0 10px;
  background:var(--pill);color:var(--edge);
  border:2.5px solid var(--edge);border-radius:99px;
  box-shadow:3px 3px 0 0 var(--edge);
  padding:6px 16px;font-size:1rem;font-weight:700;
}
.qcard .ask{margin:0 0 14px;font-size:.94rem;color:var(--dim);line-height:1.65;text-wrap:pretty}
.qcard textarea{
  width:100%;min-height:130px;padding:14px 16px;font-size:1.04rem;line-height:1.9;
  border:2.5px solid var(--edge);border-radius:12px;
  background:var(--bg);color:var(--ink);resize:vertical;
}
.qcard textarea:focus{outline:none;box-shadow:3px 3px 0 0 var(--edge)}
.qcard .cnt{text-align:right;font-size:.84rem;color:var(--dim);margin-top:8px}

.pick{display:grid;gap:9px;margin-bottom:14px}
.pick button{
  text-align:left;padding:11px 14px;font-size:.94rem;line-height:1.6;
  background:var(--bg);border:2.5px solid var(--edge);border-radius:11px;
  transition:transform .12s cubic-bezier(.2,0,0,1), box-shadow .12s cubic-bezier(.2,0,0,1);
}
.pick button:hover{background:var(--pill);box-shadow:3px 3px 0 0 var(--edge)}
.pick__none{font-size:.92rem;color:var(--dim)}

.stars{display:grid;grid-template-columns:repeat(5,1fr);gap:8px;margin-bottom:14px}
.star{
  padding:10px 0;font-size:1.3rem;text-align:center;color:var(--dim);
  background:var(--bg);border:2.5px solid var(--edge);border-radius:11px;
}
.star.on{background:#FFE04D;color:var(--edge);box-shadow:3px 3px 0 0 var(--edge)}

/* ===== 알림 ===== */
.toast{
  position:fixed;left:50%;bottom:70px;transform:translateX(-50%);z-index:200;
  background:rgba(20,20,20,.92);color:#fff;padding:11px 20px;border-radius:99px;font-size:.94rem;
  box-shadow:0 4px 16px rgba(0,0,0,.3);pointer-events:none;opacity:0;transition:opacity .2s;
  max-width:86vw;text-align:center
}
.toast.on{opacity:1}

/* ===== 좁은 화면 ===== */
@media(max-width:660px){
  .bar__title{display:none}
}
@media(max-width:560px){
  .navbtn span{display:none}
  .navbtn{padding:0 9px}
}
@media(max-width:460px){
  .ic{width:36px;height:36px}
  .ic svg{width:20px;height:20px}
  .bar{height:48px}
  .viewport{padding:16px 0;left:20px;right:20px}
}

/* ===== 인쇄 ===== */
.printonly{display:none}
@media print{
  @page{size:A4;margin:16mm}
  body{background:#fff!important;color:#000!important}
  .screen,.drawer,.scrim,.modal,.toast{display:none!important}
  .printonly{display:block!important}
  .printonly h1{font-size:19pt;margin:0 0 2mm}
  .printonly .pmeta{font-size:10pt;color:#555;margin:0 0 7mm;border-bottom:1px solid #999;padding-bottom:3mm}
  .printonly h2{font-size:12.5pt;margin:6mm 0 2mm;break-after:avoid}
  .printonly .pbox{
    border:1px solid #999;border-radius:2mm;padding:3mm 4mm;min-height:26mm;font-size:11pt;line-height:9mm;
    background:repeating-linear-gradient(transparent,transparent 8mm,#DDD 8mm,#DDD 8.2mm);
    white-space:pre-wrap;break-inside:avoid
  }
  .printonly .pq{font-size:10.5pt;line-height:1.65;border-left:2.5pt solid #888;padding-left:3mm;margin:0 0 2.5mm;break-inside:avoid}
  .printonly .pq em{display:block;font-style:normal;color:#555;font-size:9.5pt;margin-top:1mm}
}

@media (prefers-reduced-motion:reduce){
  *{animation-duration:.01ms!important;transition-duration:.01ms!important}
}
