/* ---------- 테마 ---------- */
:root, [data-theme="light"] {
  --bg: #fbfaf8; --fg: #1f1f22; --sub: #75757c; --faint: #a3a3a9;
  --surface: #ffffff; --surface-2: #f2f0ec; --line: rgba(0, 0, 0, .08);
  --accent: #c8693a; --accent-fg: #fff; --accent-soft: rgba(200, 105, 58, .12);
  --bar: rgba(251, 250, 248, .86); --shadow: 0 10px 40px rgba(30, 20, 10, .12), 0 2px 8px rgba(30, 20, 10, .06);
  --read-fg: #1f1f22; --mark-a: .42;
  color-scheme: light;
}
[data-theme="sepia"] {
  --bg: #f3ead7; --fg: #4f3f2e; --sub: #86735c; --faint: #ad9c84;
  --surface: #fbf5e8; --surface-2: #ebe0c9; --line: rgba(80, 55, 20, .12);
  --accent: #a65d27; --accent-soft: rgba(166, 93, 39, .14);
  --bar: rgba(243, 234, 215, .88); --read-fg: #4f3f2e;
}
[data-theme="green"] {
  --bg: #e4ede0; --fg: #2f3b2c; --sub: #66755f; --faint: #91a08a;
  --surface: #eef4eb; --surface-2: #d6e2d1; --line: rgba(30, 60, 20, .11);
  --accent: #4f7a3e; --accent-soft: rgba(79, 122, 62, .14);
  --bar: rgba(228, 237, 224, .88); --read-fg: #2f3b2c;
}
[data-theme="dark"] {
  --bg: #1c1c1e; --fg: #e4e4e6; --sub: #9a9aa0; --faint: #6b6b72;
  --surface: #262629; --surface-2: #313135; --line: rgba(255, 255, 255, .08);
  --accent: #e2a06a; --accent-fg: #1c1c1e; --accent-soft: rgba(226, 160, 106, .14);
  --bar: rgba(28, 28, 30, .86); --shadow: 0 10px 40px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .3);
  --read-fg: #d2d2d4; --mark-a: .32;
  color-scheme: dark;
}
[data-theme="black"] {
  --bg: #000; --fg: #cfcfd3; --sub: #85858b; --faint: #55555a;
  --surface: #121214; --surface-2: #1d1d20; --line: rgba(255, 255, 255, .09);
  --accent: #d08a55; --accent-fg: #000; --accent-soft: rgba(208, 138, 85, .14);
  --bar: rgba(0, 0, 0, .86); --shadow: 0 10px 40px rgba(0, 0, 0, .7);
  --read-fg: #a9a9ad; --mark-a: .28;
  color-scheme: dark;
}

:root {
  --ui-font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --hl-yellow: #ffd43b; --hl-green: #7bd88f; --hl-blue: #74c0fc; --hl-pink: #f9a8d4;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
/* iOS: 글자 크기 ±, 페이지 넘김처럼 같은 곳을 빠르게 두 번 누르면 화면이 확대되지 않도록 (손가락 확대는 그대로 가능) */
html { touch-action: manipulation; }
body {
  background: var(--bg); color: var(--fg); font-family: var(--ui-font);
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
  transition: background .25s, color .25s;
}
body.reading { overflow: hidden; overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
.ic { width: 20px; height: 20px; flex: none; }

/* ---------- 공용 컨트롤 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px; border-radius: 999px; font-weight: 600; font-size: 14px;
  background: var(--surface-2); transition: transform .12s, filter .15s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger, .btn.primary.danger { background: #d9463b; color: #fff; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn.full { width: 100%; border-radius: 12px; height: 44px; margin-bottom: 12px; }
.btn .ic { width: 18px; height: 18px; }

.icon-btn {
  width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 12px;
  color: var(--fg); transition: background .15s;
}
.icon-btn:hover { background: var(--line); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 9px; color: var(--sub); }
.icon-btn.sm .ic { width: 17px; height: 17px; }

.field {
  width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--fg); font: inherit; outline: none; resize: vertical;
}
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* 동기화 표시 — 서재에서는 제목 아래 상태줄, 뷰어에서는 점 하나 */
.sync-ind { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--sub); line-height: 1; }
.sync-ind.compact { width: 32px; height: 32px; justify-content: center; }
.sync-ind .dot { width: 7px; height: 7px; border-radius: 50%; background: #3fb26b; box-shadow: 0 0 0 3px rgba(63, 178, 107, .16); }
.sync-ind[data-state="pending"] .dot { background: #e5a23a; box-shadow: 0 0 0 3px rgba(229, 162, 58, .2); animation: pulse 1s infinite alternate; }
.sync-ind[data-state="offline"] .dot { background: #9a9aa0; box-shadow: 0 0 0 3px rgba(150, 150, 160, .2); }
.lib-count:not(:empty)::before { content: "·"; margin-right: 6px; color: var(--faint); }
@keyframes pulse { to { opacity: .4; } }

/* ---------- 서재 ---------- */
.lib-header {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: calc(16px + var(--safe-top)) var(--gutter) 14px;
  background: var(--bar); backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px);
  border-bottom: 1px solid var(--line);
}
.lib-brand { display: flex; align-items: center; gap: 12px; }
.lib-brand h1 { margin: 0 0 5px; font-size: 26px; font-weight: 800; letter-spacing: -.035em; line-height: 1.1; }
.lib-nav { display: flex; gap: 14px; align-items: baseline; }
.lib-nav a { color: var(--faint); text-decoration: none; transition: color .15s; }
.lib-nav a:hover { color: var(--sub); }
.lib-nav a.on { color: var(--fg); }
.notes-mode #lib-select { display: none; }
.brand-mark { width: 16px; height: 26px; border-radius: 3px 3px 0 0; background: var(--accent); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 76%, 0 100%); align-self: flex-start; margin-top: 2px; }
.lib-actions { display: flex; align-items: center; gap: 6px; }
.lib-main { padding: 28px var(--gutter) calc(64px + var(--safe-bottom)); }
:root { --gutter: max(24px, calc((100vw - 1180px) / 2)); }

/* 이어 읽기 */
#hero { display: grid; gap: 20px; margin-bottom: 40px; }
#hero:empty { display: none; }
#hero.has-side { grid-template-columns: minmax(0, 1fr) 300px; }
.hero {
  position: relative; isolation: isolate; overflow: hidden; display: flex; gap: 28px; align-items: center;
  padding: 28px 32px; border-radius: 24px;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04), inset 0 0 0 1px var(--line);
  transition: transform .25s cubic-bezier(.2, .8, .2, 1), box-shadow .25s;
}
.hero:hover { transform: translateY(-2px); box-shadow: 0 14px 34px -14px rgba(0, 0, 0, .25), inset 0 0 0 1px var(--line); }
.hero-bg { position: absolute; inset: 0; z-index: -1; overflow: hidden; }
.hero-bg img { width: 100%; height: 100%; object-fit: cover; filter: blur(50px) saturate(1.5); opacity: .32; transform: scale(1.4); }
.hero-bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 0%, color-mix(in srgb, var(--surface) 55%, transparent) 70%); }
.hero-cover { width: 116px; flex: none; }
.hero-body { min-width: 0; flex: 1; max-width: 560px; }
.hero-kicker { font-size: 12.5px; font-weight: 700; color: var(--accent); letter-spacing: .01em; }
.hero-title { font-size: 25px; font-weight: 750; margin-top: 6px; line-height: 1.25; letter-spacing: -.03em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.hero-author { color: var(--sub); font-size: 14px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-author:empty { display: none; }
.hero-progress { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.hero-progress .bar { flex: 1; height: 4px; border-radius: 9px; background: color-mix(in srgb, var(--fg) 10%, transparent); overflow: hidden; }
.hero-progress .bar span { display: block; height: 100%; background: var(--accent); border-radius: 9px; }
.hero-pct { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hero-btn {
  display: inline-flex; align-items: center; gap: 2px; margin-top: 18px; height: 38px; padding: 0 12px 0 18px;
  border-radius: 999px; background: var(--fg); color: var(--bg); font-size: 14px; font-weight: 650;
}
.hero-btn .ic { width: 16px; height: 16px; }
.ic.flip { transform: scaleX(-1); }

.hero-side { padding: 20px 20px 12px; border-radius: 24px; box-shadow: inset 0 0 0 1px var(--line); display: flex; flex-direction: column; }
.side-title { font-size: 12.5px; font-weight: 700; color: var(--sub); margin-bottom: 6px; }
.side-item { display: flex; align-items: center; gap: 12px; padding: 8px; margin: 0 -8px; border-radius: 12px; transition: background .15s; }
.side-item:hover { background: var(--surface-2); }
.side-cover { width: 36px; flex: none; border-radius: 2px 4px 4px 2px; box-shadow: 0 1px 2px rgba(0, 0, 0, .15), 0 4px 10px -4px rgba(0, 0, 0, .3); }
.side-cover .gen-frame { inset: 6cqw 6cqw 6cqw 8cqw; padding: 14cqw 4cqw 6cqw; }
.side-cover .gen-title { font-size: 7px; -webkit-line-clamp: 3; }
.side-cover .gen-rule, .side-cover .gen-author { display: none; }
.side-text { min-width: 0; flex: 1; }
.side-name { font-size: 14px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
.side-meta { font-size: 12px; color: var(--sub); margin-top: 1px; font-variant-numeric: tabular-nums; }
.side-bar { height: 3px; margin-top: 6px; border-radius: 3px; background: color-mix(in srgb, var(--fg) 9%, transparent); overflow: hidden; }
.side-bar span { display: block; height: 100%; background: var(--accent); }
@media (max-width: 900px) {
  #hero.has-side { grid-template-columns: 1fr; }
  .hero-side { display: none; }
}

/* 필터 + 검색 */
.lib-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: -2px; padding: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 999px; white-space: nowrap;
  font-size: 13.5px; font-weight: 600; color: var(--sub); box-shadow: inset 0 0 0 1px var(--line); transition: background .15s, color .15s;
}
.chip:hover { background: var(--surface-2); }
.chip.on { background: var(--fg); color: var(--bg); box-shadow: none; }
.chip-n { font-size: 12px; font-weight: 600; opacity: .55; font-variant-numeric: tabular-nums; }
.search { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 999px; background: var(--surface-2); color: var(--sub); width: min(280px, 50vw); flex: none; transition: box-shadow .15s; }
.search:focus-within { box-shadow: 0 0 0 2px var(--accent-soft), inset 0 0 0 1px var(--accent); }
.search .ic { width: 16px; height: 16px; }
.search input { border: 0; outline: 0; background: none; font: inherit; font-size: 14px; color: var(--fg); width: 100%; }
.search input::placeholder { color: var(--faint); }

/* 책 목록 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 38px 26px; }
.card { min-width: 0; }
.card-link { display: block; }
.card-link:hover .cover { transform: translateY(-4px); box-shadow: 0 2px 4px rgba(0, 0, 0, .1), 0 22px 36px -12px rgba(0, 0, 0, .35); }
.card-bar { height: 3px; margin-top: 12px; border-radius: 3px; background: color-mix(in srgb, var(--fg) 9%, transparent); overflow: hidden; }
.card-bar:empty { background: transparent; }
.card-bar span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.card-info { display: flex; align-items: flex-start; gap: 2px; margin-top: 9px; }
.card-text { flex: 1; min-width: 0; }
.card-title { font-weight: 650; font-size: 14.5px; line-height: 1.38; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; letter-spacing: -.015em; }
.card-sub { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--sub); margin-top: 3px; }
.card-author { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st { flex: none; font-variant-numeric: tabular-nums; }
.st.new { color: var(--accent); font-weight: 600; }
.st.done { color: var(--faint); }
.card-more { margin: -5px -8px 0 0; }
@media (hover: hover) {
  .card-more { opacity: 0; transition: opacity .15s; }
  .card:hover .card-more, .card-more:focus-visible { opacity: 1; }
}

.cover {
  position: relative; aspect-ratio: 2 / 3; border-radius: 3px 7px 7px 3px; overflow: hidden;
  background: var(--surface-2); box-shadow: 0 1px 2px rgba(0, 0, 0, .12), 0 10px 22px -8px rgba(0, 0, 0, .28);
  transition: transform .3s cubic-bezier(.2, .8, .2, 1), box-shadow .3s;
}
.cover::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: linear-gradient(90deg, rgba(0,0,0,.16) 0, rgba(255,255,255,.18) 2.5%, rgba(255,255,255,0) 6%, rgba(0,0,0,.06) 7%, transparent 9%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
}
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* 표지 없는 책: 천 장정 + 활자 */
.cover.gen {
  container-type: inline-size; color: #f3e9d4;
  background-color: var(--cloth);
  background-image: radial-gradient(130% 90% at 25% 0%, rgba(255, 255, 255, .16), transparent 60%), linear-gradient(180deg, transparent 40%, rgba(0, 0, 0, .22));
}
.gen-frame {
  position: absolute; inset: 7cqw 7cqw 7cqw 9cqw; border: 1px solid rgba(243, 233, 212, .35);
  display: flex; flex-direction: column; align-items: center; text-align: center; padding: 17cqw 8cqw 9cqw;
}
.gen-title {
  font-family: "Noto Serif KR", serif; font-weight: 600; font-size: clamp(10px, 11cqw, 20px); line-height: 1.38;
  word-break: keep-all; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .2);
}
.gen-rule { width: 12cqw; height: 1px; margin-top: 9cqw; background: currentColor; opacity: .5; }
.gen-author { margin-top: auto; font-size: clamp(8px, 6.4cqw, 12px); letter-spacing: .06em; opacity: .8; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.no-result { grid-column: 1 / -1; color: var(--sub); text-align: center; padding: 48px 0; }

.empty { text-align: center; padding: 12vh 20px; color: var(--sub); }
.empty-art { width: 76px; height: 76px; margin: 0 auto 18px; display: grid; place-items: center; border-radius: 24px; background: var(--accent-soft); color: var(--accent); }
.empty-art .ic { width: 34px; height: 34px; }
.empty h3 { color: var(--fg); margin: 0 0 6px; font-size: 19px; }
.empty p { margin: 0 0 20px; line-height: 1.7; }

.drop-overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; pointer-events: none;
  background: color-mix(in srgb, var(--bg) 80%, transparent); opacity: 0; transition: opacity .15s;
}
.drop-overlay div { padding: 34px 44px; border: 2px dashed var(--accent); border-radius: 22px; color: var(--accent); font-weight: 600; background: var(--surface); }
.drop-overlay.show { opacity: 1; }

/* ---------- 뷰어 ---------- */
#reader-view { position: fixed; inset: 0; background: var(--bg); }
.stage { position: absolute; inset: 0; }

.txt-scroll { position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.txt-content {
  max-width: var(--read-width); margin: 0 auto;
  padding: calc(56px + var(--safe-top)) 24px calc(80px + var(--safe-bottom));
}
.txt-text {
  font-family: var(--read-font); font-size: var(--read-size); line-height: var(--read-lh); color: var(--read-fg);
  word-break: keep-all; overflow-wrap: anywhere; white-space: pre-wrap; letter-spacing: -.003em;
}
.txt-content .blk { content-visibility: auto; contain-intrinsic-size: auto 2400px; }
.txt-text p { margin: 0; }
.txt-text p + p { margin-top: .3em; }
.txt-text p.blank { height: .55em; }
.txt-text p.chap { font-weight: 700; font-size: 1.15em; margin: 1.6em 0 .8em; letter-spacing: -.01em; }
.txt-text p:first-child.chap { margin-top: 0; }

/* TXT 페이지 모드 */
.txt-paged { position: absolute; inset: 0; overflow: hidden; touch-action: pan-y pinch-zoom; }
.txt-page-view {
  position: absolute; top: calc(52px + var(--safe-top)); bottom: calc(48px + var(--safe-bottom));
  left: 50%; transform: translateX(-50%); overflow: hidden;
  font-size: var(--read-size); width: min(calc(100% - 48px), var(--read-width));
}
.txt-paged.spread .txt-page-view { width: min(calc(100% - 80px), calc(var(--read-width) * 2 + 72px)); }
.txt-cols { height: 100%; column-fill: auto; transition: transform .26s cubic-bezier(.2, .8, .2, 1); will-change: transform; }
.txt-cols p { orphans: 2; widows: 2; }
.txt-cols p.chap { break-after: avoid; }
.txt-paged.spread .txt-page-view::after {
  content: ""; position: absolute; top: 4%; bottom: 4%; left: 50%; width: 1px; background: var(--line);
}

mark.hl { color: inherit; border-radius: 2px; padding: .05em 0; cursor: pointer; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
mark.hl { --c: var(--hl-yellow); background: color-mix(in srgb, var(--c) calc(var(--mark-a) * 100%), transparent); }
mark.hl-green { --c: var(--hl-green); }
mark.hl-blue { --c: var(--hl-blue); }
mark.hl-pink { --c: var(--hl-pink); }
mark.hl.has-note { text-decoration: underline dotted color-mix(in srgb, var(--fg) 45%, transparent); text-underline-offset: .25em; }
/* 밑줄 · 물결 밑줄: 밝은 색도 잘 보이게 글자색을 조금 섞는다 */
mark.hl.st-underline, mark.hl.st-wavy { --line: color-mix(in srgb, var(--c) 80%, var(--read-fg)); background: none; text-underline-offset: .24em; text-decoration-skip-ink: none; }
mark.hl.st-underline { text-decoration: underline 2px var(--line); }
mark.hl.st-wavy { text-decoration: underline wavy var(--line); text-decoration-thickness: 1.5px; }
mark.hl.st-underline.has-note, mark.hl.st-wavy.has-note { background: color-mix(in srgb, var(--c) 14%, transparent); }
/* EPUB: epub.js가 본문 위에 그리는 밑줄 (색은 g의 stroke) */
.epub-host g[class^="hlu-"] line, .epub-host g[class^="hlw-"] line, .epub-host g[class^="hlw-"] path { stroke: inherit; stroke-width: 2px; stroke-linecap: round; }
.epub-host g[class^="hlw-"] path { stroke-width: 1.6px; }
.epub-host g[class^="hlu-"] rect, .epub-host g[class^="hlw-"] rect { stroke: none; }

.epub-host {
  position: absolute; top: calc(44px + var(--safe-top)); bottom: calc(40px + var(--safe-bottom));
  left: 50%; transform: translateX(-50%); width: min(calc(100% - 40px), var(--epub-width, 760px));
}
.epub-host.scrolled { top: 0; bottom: 0; width: min(100%, var(--epub-width, 760px)); }

.ribbon {
  position: absolute; top: 0; right: max(18px, calc(50% - var(--read-width) / 2 - 10px)); z-index: 4; width: 18px; height: 34px;
  background: var(--accent); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 75%, 0 100%); pointer-events: none;
  animation: drop .3s ease-out;
}
#reader-view[data-type="epub"] .ribbon { right: 22px; }
#reader-view.bars .ribbon { opacity: 0; }
@keyframes drop { from { transform: translateY(-100%); } }

.rbar {
  position: absolute; left: 0; right: 0; z-index: 6; background: var(--bar);
  backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px);
  transition: transform .28s cubic-bezier(.2, .8, .2, 1), opacity .2s; opacity: 0; pointer-events: none;
}
.rbar.top { top: 0; display: flex; align-items: center; gap: 2px; padding: calc(6px + var(--safe-top)) 8px 6px; border-bottom: 1px solid var(--line); transform: translateY(-100%); }
.rbar.bottom { bottom: 0; padding: 12px 20px calc(12px + var(--safe-bottom)); border-top: 1px solid var(--line); transform: translateY(100%); }
#reader-view.bars .rbar { transform: none; opacity: 1; pointer-events: auto; }
.r-titles { flex: 1; min-width: 0; padding: 0 6px; }
.r-title-row { display: flex; align-items: center; gap: 4px; min-width: 0; }
.r-title { font-weight: 650; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
.sync-ind.mini { width: 16px; height: 16px; justify-content: center; flex: none; }
.sync-ind.mini .dot { width: 6px; height: 6px; box-shadow: none; }
.r-chapter { font-size: 12px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn.aa { font-weight: 700; font-size: 17px; font-family: "Noto Serif KR", serif; }
#r-bookmark.on { color: var(--accent); }
#r-bookmark.on .ic { fill: currentColor; }

.r-progress { display: flex; align-items: center; gap: 6px; max-width: 760px; margin: 0 auto; }
.r-progress .icon-btn:disabled { opacity: .3; cursor: default; background: none; }
.r-meta-row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; max-width: 760px; margin: 2px auto 0; padding: 0 40px; }
.r-meta { font-size: 12.5px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-pct { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; flex: none; }
input[type="range"] {
  --fill: 0%; flex: 1; appearance: none; -webkit-appearance: none; height: 22px; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--accent) var(--fill), var(--surface-2) var(--fill)); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--accent) var(--fill), var(--surface-2) var(--fill)); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: var(--surface); border: 0; box-shadow: 0 1px 4px rgba(0,0,0,.3), 0 0 0 1px var(--line); }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 0; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
input[type="range"]:disabled { opacity: .4; cursor: default; }

/* 메뉴를 숨겼을 때 아래 상태줄 — 본문 폭에 맞춰 왼쪽 장 이름, 오른쪽 진행률 */
.r-mini {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; pointer-events: none; transition: opacity .2s;
  display: flex; justify-content: space-between; align-items: center; gap: 24px;
  height: calc(40px + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  font-size: var(--read-size); padding-inline: max(24px, calc(50% - var(--read-width) / 2));
  background: linear-gradient(to top, var(--bg) 60%, color-mix(in srgb, var(--bg) 0%, transparent));
}
#reader-view[data-type="epub"] .r-mini { padding-inline: max(20px, calc(50% - var(--epub-width, 760px) / 2)); }
.r-mini span { font-size: 11.5px; color: var(--faint); font-family: var(--ui-font); letter-spacing: .01em; }
.r-mini-l { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-mini-r { flex: none; font-variant-numeric: tabular-nums; white-space: pre; }
#reader-view.bars .r-mini { opacity: 0; }

.loading { position: absolute; inset: 0; z-index: 8; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--sub); background: var(--bg); padding: 24px; text-align: center; }
.loading .spinner { margin-bottom: 14px; }
.loading-title { font-size: 17px; font-weight: 700; color: var(--fg); letter-spacing: -.02em; }
.loading-sub { font-size: 13px; }
.spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--surface-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 서랍 ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .32); opacity: 0; transition: opacity .25s; }
.backdrop.clear { background: transparent; }
.drawer { position: fixed; inset: 0; z-index: 20; }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(400px, 92vw); display: flex; flex-direction: column;
  background: var(--surface); box-shadow: var(--shadow); transform: translateX(100%); transition: transform .28s cubic-bezier(.2, .8, .2, 1);
  padding-top: var(--safe-top);
}
.drawer.open .backdrop { opacity: 1; }
.drawer.open .drawer-panel { transform: none; }
.drawer-head { display: flex; align-items: flex-start; gap: 8px; padding: 20px 12px 16px 20px; }
.drawer-book { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; }
.drawer-cover { width: 50px; flex: none; border-radius: 2px 5px 5px 2px; }
.drawer-cover .gen-title { font-size: 8px; -webkit-line-clamp: 3; }
.drawer-cover .gen-rule, .drawer-cover .gen-author { display: none; }
.db-text { min-width: 0; flex: 1; }
.db-title { font-size: 16px; font-weight: 700; line-height: 1.3; letter-spacing: -.02em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.db-sub { font-size: 12.5px; color: var(--sub); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.db-bar { height: 3px; margin-top: 8px; border-radius: 3px; background: color-mix(in srgb, var(--fg) 9%, transparent); overflow: hidden; }
.db-bar span { display: block; height: 100%; background: var(--accent); }
.drawer-tabs { padding: 0 16px 12px; border-bottom: 1px solid var(--line); }
.tabs { flex: 1; display: flex; gap: 4px; padding: 3px; border-radius: 11px; background: var(--surface-2); }
.tabs button { flex: 1; height: 32px; border-radius: 8px; font-size: 13.5px; font-weight: 600; color: var(--sub); transition: all .15s; }
.tab-n { margin-left: 5px; font-size: 11.5px; opacity: .6; font-variant-numeric: tabular-nums; }
.tabs button.active { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.drawer-body { flex: 1; overflow-y: auto; padding: 14px 14px calc(24px + var(--safe-bottom)); overscroll-behavior: contain; }
.toc-item { display: block; width: 100%; text-align: left; padding: 11px 12px; border-radius: 10px; font-size: 14.5px; line-height: 1.4; transition: background .12s; }
.toc-item:hover { background: var(--surface-2); }
.toc-item.lv1 { padding-left: 28px; font-size: 14px; color: var(--sub); }
.toc-item.lv2, .toc-item.lv3 { padding-left: 44px; font-size: 13.5px; color: var(--sub); }
.toc-item.current { color: var(--accent); font-weight: 650; background: var(--accent-soft); position: relative; }
.drawer-empty { text-align: center; color: var(--sub); padding: 40px 16px; }
.drawer-empty strong { color: var(--fg); }
.drawer-empty p { font-size: 13.5px; line-height: 1.6; margin: 6px 0 0; }

.note-item { display: flex; align-items: flex-start; gap: 4px; border-radius: 12px; padding: 4px 4px 4px 0; transition: background .12s; }
.note-item + .note-item { border-top: 1px solid var(--line); }
.note-item:hover { background: var(--surface-2); }
.note-main { flex: 1; min-width: 0; text-align: left; padding: 10px 6px 10px 12px; }
.note-top { display: flex; gap: 8px; align-items: baseline; font-size: 12px; color: var(--sub); }
.note-pct { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.note-chap { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-text { margin-top: 4px; font-size: 14px; line-height: 1.55; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.note-quote { margin-top: 6px; font-size: 14px; line-height: 1.6; padding-left: 11px; border-left: 3px solid var(--hl); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; font-family: var(--read-font); }
.note-memo { margin-top: 8px; font-size: 13.5px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); white-space: pre-wrap; }
.note-meta { margin-top: 6px; font-size: 11.5px; color: var(--faint); }
.note-item .icon-btn { margin-top: 8px; }

/* ---------- 시트 ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; }
.sheet {
  position: absolute; left: 50%; bottom: 0; width: min(480px, 100%); transform: translate(-50%, 105%);
  background: var(--surface); border-radius: 22px 22px 0 0; box-shadow: var(--shadow);
  padding: 8px 20px calc(20px + var(--safe-bottom)); transition: transform .3s cubic-bezier(.2, .8, .2, 1);
}
@media (min-width: 700px) { .sheet { bottom: 20px; border-radius: 22px; } }
.sheet-wrap.open .sheet { transform: translate(-50%, 0); }
.sheet-handle { width: 38px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 10px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.set-row + .set-row { border-top: 1px solid var(--line); }
.set-label { font-size: 14px; font-weight: 600; color: var(--sub); flex: none; }
.swatches { display: flex; gap: 8px; }
.swatch { width: 38px; height: 38px; border-radius: 50%; font-family: "Noto Serif KR", serif; font-weight: 600; font-size: 14px; box-shadow: inset 0 0 0 1px rgba(128, 128, 128, .35); transition: transform .12s; }
.swatch.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.swatch:active { transform: scale(.92); }
.seg { display: flex; padding: 3px; border-radius: 11px; background: var(--surface-2); gap: 2px; }
.seg button { padding: 0 13px; height: 32px; border-radius: 8px; font-size: 13.5px; font-weight: 600; color: var(--sub); }
.seg button.on { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.stepper { display: flex; align-items: center; gap: 4px; padding: 3px; border-radius: 11px; background: var(--surface-2); }
.stepper button { width: 44px; height: 32px; border-radius: 8px; font-weight: 600; font-size: 13px; }
.stepper button.big { font-size: 18px; }
.stepper button:hover { background: var(--surface); }
.stepper span { min-width: 38px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

.action-sheet {
  position: fixed; z-index: 15; left: 50%; bottom: calc(16px + var(--safe-bottom)); width: min(440px, calc(100% - 24px));
  transform: translate(-50%, 20px); opacity: 0; transition: transform .2s, opacity .2s;
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); padding: 12px 14px; border: 1px solid var(--line);
}
.action-sheet.open { transform: translate(-50%, 0); opacity: 1; }
.action-sheet.top { top: calc(16px + var(--safe-top)); bottom: auto; transform: translate(-50%, -20px); }
.action-sheet.top.open { transform: translate(-50%, 0); }
.action-quote { font-size: 13px; color: var(--sub); line-height: 1.5; padding: 2px 4px 10px; border-bottom: 1px solid var(--line); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.hl-styles { margin-top: 10px; }
.hl-styles button { flex: 1; }
.hl-styles .sample { text-underline-offset: .22em; text-decoration-skip-ink: none; }
.sample.st-highlight { background: color-mix(in srgb, var(--hl-yellow) 45%, transparent); border-radius: 2px; padding: 0 2px; }
.sample.st-underline { text-decoration: underline 2px color-mix(in srgb, var(--hl-yellow) 80%, var(--fg)); }
.sample.st-wavy { text-decoration: underline wavy color-mix(in srgb, var(--hl-yellow) 80%, var(--fg)); text-decoration-thickness: 1.5px; }
.action-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 10px; }
.colors { display: flex; gap: 10px; }
.color-dot { width: 30px; height: 30px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1); transition: transform .12s; }
.color-dot:hover { transform: scale(1.1); }
.color-dot.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }
.action-btns { display: flex; gap: 2px; }
.act { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--sub); padding: 4px 8px; border-radius: 9px; }
.act:hover { background: var(--surface-2); }
.act .ic { width: 19px; height: 19px; color: var(--fg); }
.act.danger, .act.danger .ic { color: #d9463b; }

/* ---------- 독서노트 ---------- */
.notes-mode .seg button { padding: 0 16px; height: 34px; }
.notes-chips { margin-bottom: 18px; }
.notes-body { max-width: 760px; }
.nt-day { margin: 26px 0 8px; font-size: 13px; font-weight: 700; color: var(--sub); letter-spacing: -.01em; }
.nt-day:first-child { margin-top: 0; }
.nt-group { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 4px 6px; }
.nt-group .note-item { border-radius: 0; }
.nt-group .note-item:hover { background: none; }
.nt-item .note-main { padding: 12px 6px 12px 10px; }
.nt-open { display: block; width: 100%; text-align: left; border-radius: 8px; }
.nt-open:hover .note-quote, .nt-open:hover .note-text { color: var(--fg); }
.nt-from { display: inline-block; max-width: 100%; margin-bottom: 6px; font-size: 12.5px; font-weight: 700; color: var(--fg); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nt-from:hover { text-decoration: underline; }
.nt-kind { font-weight: 700; color: var(--sub); }
.nt-kind.k-bm { color: var(--accent); }
.nt-item .note-quote { -webkit-line-clamp: 8; }
.nt-actions { display: flex; flex-direction: column; gap: 2px; padding-top: 6px; }
.nt-actions .icon-btn { margin-top: 0; color: var(--faint); }
.nt-actions .icon-btn:hover { color: var(--fg); }
.nt-books { display: flex; flex-direction: column; gap: 10px; }
.nt-book-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); color: inherit; text-decoration: none; transition: background .12s; }
.nt-book-row:hover { background: var(--surface-2); }
.nt-cover { width: 46px; flex: none; }
.nt-cover.lg { width: 72px; }
.nt-book-text { flex: 1; min-width: 0; }
.nt-book-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nt-book-author { font-size: 12.5px; color: var(--sub); margin-top: 2px; }
.nt-book-counts { font-size: 13px; margin-top: 6px; }
.nt-book-meta { font-size: 11.5px; color: var(--faint); margin-top: 3px; }
.nt-chev { color: var(--faint); flex: none; }
.nt-book-head { margin-bottom: 18px; }
.nt-backlink { display: inline-flex; align-items: center; gap: 2px; font-size: 13.5px; font-weight: 600; color: var(--sub); text-decoration: none; margin: 0 0 12px -4px; }
.nt-backlink .ic { width: 18px; height: 18px; }
.nt-book-card { display: flex; gap: 16px; align-items: center; }
.nt-book-card .nt-book-title { font-size: 19px; white-space: normal; }
.nt-book-actions { display: flex; gap: 6px; margin-top: 12px; }
.nt-book-actions .btn { text-decoration: none; display: inline-flex; align-items: center; gap: 5px; }
.nt-book-actions .ic { width: 15px; height: 15px; }
.note-quote.st-underline { text-decoration: underline 2px color-mix(in srgb, var(--hl) 80%, var(--fg)); text-underline-offset: .24em; text-decoration-skip-ink: none; }
.note-quote.st-wavy { text-decoration: underline wavy color-mix(in srgb, var(--hl) 80%, var(--fg)); text-decoration-thickness: 1.5px; text-underline-offset: .24em; text-decoration-skip-ink: none; }

/* ---------- 대화상자 / 메뉴 / 토스트 ---------- */
.dialog {
  border: 0; padding: 22px; border-radius: 20px; width: min(420px, calc(100% - 32px));
  background: var(--surface); color: var(--fg); box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(0, 0, 0, .35); backdrop-filter: blur(2px); }
.dialog h3 { margin: 0 0 8px; font-size: 18px; }
.dialog .hint { color: var(--sub); font-size: 13px; margin: 6px 0 12px; line-height: 1.55; }
.dialog .error { color: #d9463b; font-size: 13px; min-height: 1em; margin: 8px 0 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
#ask-input-wrap .field { margin-top: 4px; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--sub); }
.field-label .field { margin-top: 6px; }
.info-box { margin-top: 14px; padding: 14px; border-radius: 14px; background: var(--surface-2); }
.info-title { font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.info-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; padding: 3px 0; }
.info-row span:first-child { color: var(--sub); }
.info-row code { font-size: 13px; user-select: all; word-break: break-all; }
.info-box .hint { margin-bottom: 0; }

.menu { position: fixed; z-index: 30; width: 200px; padding: 6px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); border: 1px solid var(--line); }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border-radius: 9px; font-size: 14px; text-align: left; }
.menu button:hover { background: var(--surface-2); }
.menu button .ic { width: 17px; height: 17px; color: var(--sub); }
.menu .danger, .menu .danger .ic { color: #d9463b; }
.menu-sep { height: 1px; margin: 4px 6px; background: var(--line); }
#ask-message { white-space: pre-line; }

.toast {
  position: fixed; z-index: 60; left: 50%; top: calc(16px + var(--safe-top)); transform: translate(-50%, -150%);
  display: flex; align-items: center; gap: 12px; width: max-content; max-width: min(460px, calc(100% - 32px)); padding: 10px 10px 10px 16px;
  background: var(--fg); color: var(--bg); border-radius: 13px; font-size: 13.5px; font-weight: 500; line-height: 1.45; text-wrap: balance;
  box-shadow: var(--shadow); transition: transform .3s cubic-bezier(.2, .8, .2, 1), opacity .3s, visibility .3s;
  pointer-events: none; opacity: 0; visibility: hidden;
}
.toast.show { transform: translate(-50%, 0); pointer-events: auto; opacity: 1; visibility: visible; }
.toast:not(:has(.toast-btn)) { padding-right: 16px; }
.toast-btn { flex: none; padding: 6px 12px; border-radius: 9px; background: var(--accent); color: var(--accent-fg); font-weight: 700; font-size: 13px; }

/* ---------- 모바일 ---------- */
@media (max-width: 600px) {
  :root { --gutter: 16px; }
  .lib-header { padding-top: calc(12px + var(--safe-top)); padding-bottom: 10px; padding-right: 10px; }
  .lib-brand h1 { font-size: 21px; margin-bottom: 4px; }
  .lib-nav { gap: 10px; }
  .notes-mode .lib-toolbar { flex-direction: column; }
  .nt-day { margin-top: 20px; }
  .brand-mark { width: 14px; height: 22px; }
  .lib-main { padding-top: 18px; }
  #lib-add span:last-child { display: none; }
  #lib-add { width: 40px; height: 40px; padding: 0; }
  #lib-add .ic { width: 20px; height: 20px; }
  .grid { grid-template-columns: repeat(3, 1fr); gap: 26px 14px; }
  .card-title { font-size: 13px; }
  .card-sub { font-size: 11.5px; }
  .card-bar { margin-top: 9px; }
  #hero { margin-bottom: 28px; }
  .hero { padding: 18px; gap: 18px; border-radius: 20px; }
  .hero-cover { width: 88px; }
  .hero-title { font-size: 19px; }
  .hero-progress { margin-top: 12px; }
  .hero-btn { margin-top: 14px; height: 34px; font-size: 13px; }
  .lib-toolbar { flex-direction: column-reverse; align-items: stretch; gap: 12px; margin-bottom: 18px; }
  .search { width: 100%; }
  .txt-content { padding-left: 20px; padding-right: 20px; }
  .txt-page-view { width: calc(100% - 40px); }
  .epub-host { width: calc(100% - 32px); }
  .set-row { flex-wrap: wrap; }
}
@media (max-width: 380px) { .grid { grid-template-columns: repeat(2, 1fr); } }

/* 위치 계산 순간에만 사용 (txt-engine.js) */
.probing .sheet-wrap, .probing .sheet-wrap *, .probing .drawer, .probing .drawer *, .probing .action-sheet, .probing .action-sheet *,
.probing .rbar, .probing .rbar *, .probing .toast, .probing .toast *, .probing .menu, .probing .ribbon, .probing .r-mini, .probing .loading { pointer-events: none !important; }

/* 뷰어에서는 알림이 상단 메뉴를 가리지 않도록 조금 아래에 */
body.reading .toast { top: calc(64px + var(--safe-top)); }

/* 저장·동기화 선택 */
.conn-title { margin-top: 18px; font-size: 13px; font-weight: 700; color: var(--sub); }
.conn-options { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.conn-opt {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--line); transition: box-shadow .15s, background .15s;
}
.conn-opt:has(input:checked) { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-soft); }
.conn-opt.disabled { opacity: .5; cursor: default; }
.conn-opt input { margin: 3px 0 0; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.conn-text { display: flex; flex-direction: column; gap: 2px; }
.conn-text strong { font-size: 14.5px; }
.conn-text > span { font-size: 12.5px; color: var(--sub); line-height: 1.5; }
.soon { font-style: normal; font-size: 11px; font-weight: 700; color: var(--sub); background: var(--surface-2); padding: 1px 6px; border-radius: 6px; margin-left: 4px; }
.server-fields { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; padding: 14px; border-radius: 14px; background: var(--surface-2); }
.server-fields .field { background: var(--surface); }
.field-label .opt { font-weight: 500; color: var(--faint); }
.test-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.test-result { font-size: 13px; line-height: 1.5; color: var(--sub); flex: 1; min-width: 160px; }
.test-result.ok { color: #2f8f5b; }
.test-result.err { color: #d9463b; }
.conn-note:empty { display: none; }
.sync-ind[data-state="local"] .dot { background: #8a94a6; box-shadow: 0 0 0 3px rgba(138, 148, 166, .2); }
.server-fields .btn { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.dialog { max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; }
/* iOS는 글자가 16px보다 작은 입력칸을 누르면 화면을 확대해 버린다 → 터치 기기에서는 16px */
@media (pointer: coarse) { .search input, .field { font-size: 16px; } }
/* 홈 화면 웹 앱(전체 화면)·가로 모드: 카메라·상태 표시줄이 왼쪽/오른쪽에 있는 기기에서 버튼과 본문이 가리지 않게 */
.lib-header, .lib-main { padding-left: max(var(--gutter), var(--safe-left)); padding-right: max(var(--gutter), var(--safe-right)); }
#reader-view { left: var(--safe-left); right: var(--safe-right); }
.drawer-panel { padding-right: var(--safe-right); }
.sheet { padding-left: max(20px, var(--safe-left)); padding-right: max(20px, var(--safe-right)); }

/* 아이폰·아이패드 홈 화면 추가 안내 */
.install-tip { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 20px; padding: 12px 8px 12px 16px; border-radius: 12px; background: var(--accent-soft); color: var(--fg); font-size: 14px; line-height: 1.55; }
.install-tip[hidden] { display: none; }
.install-tip p { margin: 0; flex: 1; }
.install-tip b { color: var(--accent); }

/* 도움말 */
.dialog.help { width: min(520px, calc(100% - 32px)); }
.help section { margin-top: 16px; }
.help h4 { margin: 0 0 6px; font-size: 15px; }
.help p, .help ul { margin: 0; color: var(--sub); font-size: 14px; line-height: 1.6; }
.help ul { padding-left: 18px; }
.help li + li { margin-top: 4px; }
.help b { color: var(--fg); font-weight: 600; }

/* 내 글꼴 */
.user-font { display: flex; align-items: center; gap: 6px; min-width: 0; }
.user-font-name { font-size: 13px; color: var(--sub); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }

/* 여러 권 선택 */
.icon-btn.on { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: #d9463b; color: #fff; }
.btn:disabled { opacity: .45; pointer-events: none; }
.select-bar { position: sticky; top: 8px; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; padding: 10px 10px 10px 16px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.select-bar[hidden] { display: none; }
.select-count { font-weight: 600; font-size: 14px; }
.select-actions { display: flex; gap: 6px; }
.selecting .card-more { display: none; }
.card-link { position: relative; }
.pick-mark { position: absolute; top: 8px; right: 8px; z-index: 2; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: rgba(0, 0, 0, .35); border: 2px solid #fff; color: #fff; }
.pick-mark .ic { width: 15px; height: 15px; }
.card.picked .pick-mark { background: var(--accent); border-color: var(--accent); }
.card.picked .cover { outline: 3px solid var(--accent); outline-offset: 3px; }
.selecting .card-link:hover .cover { transform: none; }
