:root {
  --yellow: #ffd618; --ink: #222; --sub: #666; --mute: #999; --line: #e8e8e8; --box: #f3f3f3; --best: #f4364c;
  --bg: #fff; --fg: #222; --bar: #fff;
  --font: "Pretendard", -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  --serif: "Noto Serif KR", "Batang", "AppleMyungjo", Georgia, serif;
  --myeongjo: "Nanum Myeongjo", "Myungjo", "Noto Serif KR", serif;
  --fs: 20px; --lh: 2; --mx: 24px; --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: #fff; color: #000; font-family: var(--font); font-size: 16px; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg { display: block; }
.ic { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* 데스크톱에서도 폰(412px) 폭으로 */
#app { width: 100%; max-width: 412px; margin: 0 auto; min-height: 100vh; position: relative; background: #fff; }
@media (min-width: 440px) { html { background: #e9e9ec; } body { box-shadow: none; } #app { box-shadow: 0 0 0 1px #d6d6da; } }

/* ── 시리즈 홈 ── */
.hdr { position: fixed; top: 0; z-index: 50; width: 100%; max-width: 412px; height: 56px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; color: #fff; transition: background .15s, color .15s; }
.hdr.solid { background: #fff; color: #000; box-shadow: 0 1px 0 var(--line); }
.hdr .grp { display: flex; gap: 16px; align-items: center; }
.hdr .ttl { position: absolute; left: 90px; right: 90px; text-align: center; font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; }
.hdr.solid .ttl { opacity: 1; }
.hero { position: relative; height: 392px; overflow: hidden; background: #555; }
.hero .bg { position: absolute; inset: -30px; background-size: cover; background-position: center; filter: blur(22px) saturate(.9); opacity: .9; }
.hero .shade { position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(0,0,0,.12) 0, rgba(0,0,0,.05) 40%, #fff 100%); }
.hero .cov { position: absolute; top: 58px; left: 50%; width: 156px; height: 234px; margin-left: -78px; border-radius: 6px; overflow: hidden; background: #bbb; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.hero .cov img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero .info { position: absolute; top: 310px; left: 0; right: 0; text-align: center; padding: 0 20px; }
.hero h1 { margin: 0; font-size: 21px; line-height: 26px; font-weight: 700; color: #000; }
.hero .au { margin: 3px 0 0; font-size: 12px; line-height: 16px; color: var(--sub); }
.hero .meta { margin: 6px 0 0; display: flex; justify-content: center; gap: 12px; font-size: 12px; line-height: 17px; color: var(--sub); }
.hero .meta span { display: inline-flex; align-items: center; gap: 3px; }
.hero .meta .ic { width: 14px; height: 14px; stroke-width: 1.6; }
.tabs { position: sticky; top: 56px; z-index: 40; height: 44px; background: #fff; display: flex; justify-content: center; padding: 0 4px; }
.tabs button { position: relative; width: 52px; height: 44px; font-size: 14px; font-weight: 700; color: var(--mute); }
.tabs button.on { color: #000; }
.tabs button.on::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: 6px; height: 2px; background: #000; }
.body { padding: 4px 0 96px; }
.ticket { margin: 8px 11px 0; background: var(--box); border-radius: 8px; }
.ticket .r1, .ticket .r2 { display: flex; align-items: center; justify-content: space-between; height: 48px; padding: 0 18px; }
.ticket .r1 { border-bottom: 1px solid #e3e3e3; }
.ticket b { font-size: 13px; }
.ticket .v { font-size: 13px; margin-left: 4px; }
.ticket .sep { display: inline-block; width: 1px; height: 10px; background: #d0d0d0; margin: 0 10px; }
.ticket .chg { height: 28px; padding: 0 12px; border-radius: 14px; background: var(--yellow); font-size: 12px; font-weight: 700; }
.ticket .go { font-size: 12px; font-weight: 700; }
.ticket .go.wait { color: var(--sub); font-weight: 400; }
.lh { display: flex; align-items: center; justify-content: space-between; padding: 22px 17px 6px; font-size: 12px; font-weight: 700; }
.lh .rt { display: flex; gap: 20px; color: var(--sub); }
.lh .rt button { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; color: var(--sub); }
.lh .rt button.on { color: #000; }
.lh .ic { width: 16px; height: 16px; stroke-width: 1.7; }
.row { display: flex; align-items: center; gap: 14px; padding: 4px 11px; height: 92px; width: 100%; text-align: left; }
.row .th { position: relative; flex: none; width: 56px; height: 84px; border-radius: 4px; overflow: hidden; background: #ccc; }
.row .th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.row.locked .th img, .row.expired .th img { opacity: .55; }
.row .tx { min-width: 0; flex: 1; }
.row .t { font-size: 14px; line-height: 20px; color: #000; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row .d { margin-top: 2px; font-size: 12px; line-height: 17px; color: var(--mute); display: flex; align-items: center; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 3px; height: 17px; padding: 0 5px; border-radius: 4px; border: 1px solid #d7d7d7; font-size: 10px; font-weight: 700; color: var(--sub); }
.tag.rent { border: 0; padding: 0; color: var(--sub); font-size: 11px; font-weight: 400; }
.tag.rent .ic { width: 13px; height: 13px; color: #e0a800; stroke-width: 2; }
.row .lock { color: #b5b5b5; }
.more { display: block; margin: 14px auto; color: var(--sub); font-size: 13px; padding: 10px 20px; }
.empty { padding: 60px 20px; text-align: center; color: var(--mute); font-size: 13px; }
.fixbar { position: fixed; bottom: 0; z-index: 45; width: 100%; max-width: 412px; padding: 8px 8px calc(8px + var(--safe-b)); background: #fff; }
.fixbar .box { display: flex; height: 54px; border-radius: 12px; background: var(--yellow); color: var(--ink); }
.fixbar .main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding-left: 12px; }
.fixbar .main b { font-size: 14px; line-height: 20px; }
.fixbar .main span { font-size: 12px; line-height: 17px; color: #000; max-width: 280px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.fixbar .ls { width: 56px; display: grid; place-items: center; }
.info-tab { padding: 20px 18px; font-size: 14px; line-height: 1.7; color: #333; white-space: pre-wrap; }
.info-tab h3 { margin: 0 0 8px; font-size: 14px; }

/* ── 댓글 ── */
.cm-hdr { position: sticky; top: 0; z-index: 40; height: 56px; padding: 0 18px; background: #fff; display: flex; align-items: center; justify-content: space-between; }
.cm-hdr h2 { margin: 0; font-size: 16px; font-weight: 700; }
.cm-tabs { display: flex; border-bottom: 1px solid var(--line); position: sticky; top: 56px; background: #fff; z-index: 39; }
.cm-tabs button { flex: 1; height: 48px; font-size: 16px; font-weight: 700; color: var(--mute); position: relative; }
.cm-tabs button.on { color: #000; }
.cm-tabs button.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: #000; }
.cm-sort { display: flex; justify-content: space-between; align-items: center; padding: 14px 17px 4px; font-size: 12px; font-weight: 700; }
.cm-sort button { display: inline-flex; gap: 4px; align-items: center; color: var(--sub); font-size: 12px; font-weight: 700; }
.cm-sort .ic { width: 16px; height: 16px; }
.cm { display: flex; gap: 14px; padding: 18px 17px 0; }
.cm .av { flex: none; width: 44px; height: 44px; border-radius: 50%; overflow: hidden; background: #e6e6e6; }
.cm .av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cm .bd { flex: 1; min-width: 0; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.cm .hd { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cm .nm { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 14px; font-weight: 700; }
.cm .nm span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.best { font-style: normal; flex: none; height: 19px; padding: 0 6px; border-radius: 4px; background: var(--best); color: #fff; font-size: 11px; font-weight: 700; line-height: 19px; }
.cm .dt { flex: none; font-size: 12px; color: var(--mute); }
.cm .tx { margin: 8px 0 0; font-size: 14px; line-height: 1.6; color: #111; white-space: pre-wrap; word-break: break-word; }
.cm .tx.sp { color: var(--mute); cursor: pointer; }
.cm .ep { margin-top: 6px; font-size: 12px; color: var(--mute); }
.cm .ac { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 12px; border-radius: 14px; background: var(--box); font-size: 12px; color: var(--sub); }
.pill .ic { width: 15px; height: 15px; stroke-width: 1.6; }
.pill.sq { margin-left: auto; padding: 0 10px; }

/* ── 뷰어 ── */
body.reading { background: var(--bg); }
#reader { position: fixed; inset: 0; background: var(--bg); color: var(--fg); overflow: hidden; }
#stage { position: absolute; top: 44px; bottom: 44px; overflow: hidden; }
#content { height: 100%; column-fill: auto; font-size: var(--fs); line-height: var(--lh); transition: transform .22s ease; word-break: keep-all; overflow-wrap: break-word; font-family: var(--rf, var(--serif)); }
/* 본문 서식: 사이트가 회차마다 내려주는 Stylesheet.css 의 txt*/box* 값을 옮긴 것 (줄 간격은 사용자 설정을 따름) */
#content p { margin: 0; padding-bottom: 1em; text-align: justify; }
#content p.txt1 { text-indent: 1em; }
#content p.txt2 { font-size: .9em; text-align: center; padding-bottom: .9em; }
#content p.txt3 { font-size: 1.4em; font-weight: 700; text-align: center; padding: 1em 0 5em; }
#content p.txt4 { font-size: 1.1em; font-weight: 700; text-align: center; padding-bottom: 2em; }
#content p.txt5 { font-size: 1.2em; font-weight: 700; padding-bottom: 0; }
#content p.txt6 { font-size: 1.1em; font-weight: 700; text-align: center; padding: .5em 0 0; }   /* 장면 전환 줄 */
#content p.txt7, #content p.txt8 { font-size: .95em; margin: 0 1em; }
#content p.txt9 { font-size: .95em; padding-bottom: 0; }
#content p.bl { padding-bottom: 1em; }
#content .box1, #content .box2, #content .box3, #content .box4 { border: 1px solid; margin: 2em 0 3em; padding: 1.3em .3em .3em; break-inside: avoid; }
#content .box1 { border-radius: 15px; } #content .box3 { border: 5px ridge; } #content .box4 { border: 5px ridge; border-radius: 15px; }
#content .cover { height: var(--sh); display: flex; align-items: center; justify-content: center; break-after: column; }
#content .cover img { max-width: 92%; max-height: 72%; display: block; background: #ccc; }
#content .ill { margin: 0 0 .9em; break-inside: avoid; }
#content .ill img { display: block; width: 100%; height: auto; max-height: calc(var(--sh) - 8px); object-fit: contain; background: #ccc; }
#content h1 { font-size: 1.15em; margin: 0 0 1.4em; line-height: 1.5; }
body.scroll #reader { overflow-y: auto; }
body.scroll #stage { position: relative; top: 0; bottom: auto; overflow: visible; padding: 72px 0 120px; margin: 0 auto; max-width: 560px; }
body.scroll #content { height: auto; transform: none !important; }
body.scroll #content .cover { height: auto; padding: 8px 0 32px; }
.vbar { position: fixed; left: 0; right: 0; margin: 0 auto; width: 100%; max-width: 412px; z-index: 30; background: var(--bar); color: var(--fg); transition: transform .2s ease; }
#vtop { top: 0; height: 56px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; transform: translateY(-100%); }
#vtop .l { display: flex; align-items: center; gap: 10px; min-width: 0; }
#vtop .t { font-size: 16px; font-weight: 700; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#vbot { bottom: 0; transform: translateY(100%); border-top: 1px solid rgba(128,128,128,.25); padding-bottom: var(--safe-b); }
body.ui #vtop, body.ui #vbot { transform: none; }
.prog { position: relative; height: 25px; padding: 0 15px 0 0; display: flex; align-items: center; }
.prog input { flex: 1; margin: 0; height: 25px; -webkit-appearance: none; appearance: none; background: transparent; }
.prog input::-webkit-slider-runnable-track { height: 2px; background: rgba(128,128,128,.4); }
.prog input::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -7px; border-radius: 50%; background: var(--fg); }
.prog .n { flex: none; margin-left: 14px; font-size: 12px; color: var(--mute); }
.prog .n b { color: var(--fg); }
.acts { height: 56px; padding: 0 15px; display: flex; align-items: center; }
.acts .a { position: relative; width: 24px; height: 24px; margin-right: 56px; }
.acts .a.on { color: #e0a800; }
.acts .badge { position: absolute; left: 14px; top: -6px; min-width: 28px; height: 16px; padding: 0 5px; border-radius: 16px; background: #000; color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; }
.acts .sp { flex: 1; }
.acts .nv { width: 24px; height: 24px; margin-left: 56px; }
.acts .nv:disabled { opacity: .3; }
#vstatus { position: fixed; bottom: calc(10px + var(--safe-b)); left: 0; right: 0; text-align: center; font-size: 11px; color: var(--mute); z-index: 5; pointer-events: none; }
body.ui #vstatus { opacity: 0; }
.tip { position: fixed; top: 62px; right: 10px; z-index: 31; width: 206px; word-break: keep-all; padding: 11px 38px 11px 14px; border-radius: 6px; background: #1d8cff; color: #fff; font-size: 13px; font-weight: 700; line-height: 1.4; }
.tip::before { content: ""; position: absolute; top: -6px; right: 18px; border: 6px solid transparent; border-top: 0; border-bottom-color: #1d8cff; }
.tip button { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; border-radius: 50%; background: #fff; color: #1d8cff; font-size: 12px; line-height: 18px; }

/* 시트(설정/확인) */
#scrim { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.4); opacity: 0; pointer-events: none; transition: opacity .2s; }
#scrim.on { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; margin: 0 auto; width: 100%; max-width: 412px; background: #fff; color: #222; border-radius: 20px 20px 0 0; padding: 22px 24px calc(22px + var(--safe-b)); transform: translateY(110%); transition: transform .24s ease; }
.sheet.open { transform: none; }
.srow { display: flex; align-items: center; justify-content: space-between; min-height: 52px; font-size: 14px; }
.srow + .srow { margin-top: 2px; }
.srow.line { padding-bottom: 14px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.opt { display: flex; gap: 14px; }
.opt button { font-size: 14px; color: var(--mute); font-weight: 400; }
.opt button.on { color: #000; font-weight: 700; }
.themes { display: flex; gap: 8px; }
.themes button { width: 34px; height: 34px; border-radius: 50%; border: 2px solid transparent; display: grid; place-items: center; font-size: 12px; font-weight: 700; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.themes button.on { border-color: var(--yellow); }
.step { display: flex; align-items: center; gap: 14px; }
.step button { width: 34px; height: 34px; border-radius: 50%; border: 1px solid #ddd; display: grid; place-items: center; }
.step button:disabled { opacity: .3; }
.step .ic { width: 16px; height: 16px; stroke-width: 2.2; }
.step span { min-width: 18px; text-align: center; font-weight: 700; }
.reset { display: flex; margin: 14px auto 0; align-items: center; gap: 6px; color: var(--sub); font-size: 13px; }
.reset .ic { width: 16px; height: 16px; }
.dlg h3 { margin: 0 0 8px; font-size: 16px; }
.dlg p { margin: 0 0 18px; font-size: 14px; line-height: 1.55; color: #444; white-space: pre-line; }
.dlg .bt { display: flex; gap: 10px; }
.dlg .bt button { flex: 1; height: 46px; border-radius: 12px; background: var(--box); font-size: 14px; font-weight: 700; }
.dlg .bt button.pri { background: var(--yellow); }
#toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 80; max-width: 340px; padding: 9px 16px; border-radius: 20px; background: rgba(0,0,0,.8); color: #fff; font-size: 13px; opacity: 0; transition: opacity .2s; pointer-events: none; text-align: center; }
#toast.on { opacity: 1; }
/* 읽기 테마 */
body[data-theme=gray]  { --bg: #e0e0e0; --fg: #222; --bar: #e0e0e0; }
body[data-theme=dark]  { --bg: #222;    --fg: #bcbcbc; --bar: #222; }
body[data-theme=black] { --bg: #000;    --fg: #e8e8e8; --bar: #000; }
body[data-theme=cream] { --bg: #f6f1e5; --fg: #4e3726; --bar: #f6f1e5; }
body[data-theme=green] { --bg: #233e3b; --fg: #c8d9d7; --bar: #233e3b; }
