/* ==========================================================================
   위퀴즈 북스 — 담백한 읽기 화면.
   사이트 토큰(paper_shell.css)을 그대로 쓰고, 장식 없이 글과 여백으로만 구성한다.
   모든 선택자는 .wqb / .wqb-* 범위.
   ========================================================================== */

.wqb-page .main-wrapper > .container { max-width: 1200px; }
/* body 의 overflow-x:hidden 은 body 를 스크롤 컨테이너로 만들어 sticky 를 깨뜨린다 — clip 은 그렇지 않다. */
body.wqb-page { overflow-x: clip; overflow-y: visible; }

.wqb {
    --wqb-sans: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', sans-serif;
    --wqb-serif: 'Noto Serif KR', 'AppleMyungjo', serif;
    --wqb-ink: var(--wq-text, #e8e2d5);
    --wqb-soft: var(--wq-text-soft, #d4cebf);
    --wqb-muted: var(--wq-text-muted, #beb9aa);
    --wqb-dim: var(--wq-text-dim, #a29e90);
    --wqb-rule: var(--wq-border, #45463d);
    --wqb-accent: var(--wq-accent, #c3ab83);
    --wqb-surface: var(--wq-surface, #282925);
    --wqb-surface-2: var(--wq-surface-2, #30312c);
    --wqb-bg: var(--wq-bg, #191a18);
    --wqb-on-accent: var(--wq-on-accent, #22231e);
    /* 리더 팔레트 — 기본은 사이트와 같은 밤 배경 */
    --r-bg: var(--wqb-bg); --r-ink: #e3ddd0; --r-soft: #cbc5b7; --r-muted: #9f9a8d; --r-rule: #3a3b35;
    --r-accent: #c3ab83; --r-surface: #23241f; --r-mark: rgba(195, 171, 131, .22); --r-code: #2a2b26;
    color: var(--wqb-ink);
    font-family: var(--wqb-sans);
    word-break: keep-all;
    overflow-wrap: anywhere;
    padding-bottom: 64px;
}
.wqb *, .wqb *::before, .wqb *::after { box-sizing: border-box; }
/* styles.css 의 html.dark a / html.dark h1 (0,1,2) 를 같은 특이성 + 늦은 로드로 이긴다. */
html .wqb a { color: inherit; text-decoration: none; }
html .wqb :is(h1, h2, h3) { color: var(--wqb-ink); font-family: var(--wqb-sans); }
.wqb :where(h1, h2, h3) { margin: 0; }
.wqb [hidden] { display: none !important; }
.wqb :focus-visible { outline: 2px solid var(--wqb-accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- 공통 ---------- */
.wqb-meta { margin: 0; font-size: 13px; color: var(--wqb-muted); }
.wqb-muted { color: var(--wqb-muted); }
.wqb-kicker { margin: 0 0 6px; font-size: 13px; color: var(--wqb-muted); }
.wqb .wqb-kicker a:hover { color: var(--wqb-ink); }
.wqb .wqb-h2 { font-size: 16px; font-weight: 700; margin-bottom: 14px; }
.wqb-badge { display: inline-block; margin: 0 0 12px; padding: 2px 8px; border-radius: 6px; background: var(--wqb-surface-2); font-size: 12px; color: var(--wqb-muted); }

.wqb .wqb-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 42px; padding: 0 18px;
    border: 1px solid var(--wqb-rule); border-radius: 10px;
    background: transparent; color: var(--wqb-ink);
    font: 500 14px/1 var(--wqb-sans); cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}
.wqb .wqb-btn:hover { background: var(--wqb-surface); }
.wqb .wqb-btn--primary { background: var(--wqb-accent); border-color: var(--wqb-accent); color: var(--wqb-on-accent); font-weight: 600; }
.wqb .wqb-btn--primary:hover { background: var(--wq-accent-hover, #d2bd99); border-color: var(--wq-accent-hover, #d2bd99); }
.wqb .wqb-btn--ghost { border-color: transparent; color: var(--wqb-muted); }
.wqb .wqb-btn--danger { border-color: transparent; color: #e0a196; }
.wqb .wqb-btn--sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.wqb .wqb-btn[disabled] { opacity: .45; pointer-events: none; }

/* ---------- 상단 ---------- */
.wqb-bar { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 8px; }
.wqb .wqb-back { font-size: 14px; color: var(--wqb-muted); }
.wqb .wqb-back:hover { color: var(--wqb-ink); }

/* ---------- 표지: 단색 면 + 책등 그림자 + 제목 ---------- */
.wqb-cover {
    --c-bg: #5d4d37; --c-ink: #f1e9da;
    position: relative; display: flex; flex-direction: column;
    width: 100%; aspect-ratio: 3 / 4.2; padding: 13% 11% 11% 17%;
    border-radius: 3px 7px 7px 3px; color: var(--c-ink);
    background:
        linear-gradient(90deg, rgba(0,0,0,.28) 0, rgba(0,0,0,.08) 5%, rgba(255,255,255,.10) 6.5%, rgba(255,255,255,0) 9%),
        linear-gradient(180deg, rgba(255,255,255,.06), rgba(0,0,0,.08)),
        var(--c-bg);
    box-shadow: 0 1px 2px rgba(0,0,0,.25), 0 8px 18px -8px rgba(0,0,0,.55);
    overflow: hidden;
}
.wqb-cover--oak    { --c-bg: #6a5638; --c-ink: #f4ecdc; }
.wqb-cover--ink    { --c-bg: #30343b; --c-ink: #ebe7de; }
.wqb-cover--forest { --c-bg: #355041; --c-ink: #edede2; }
.wqb-cover--wine   { --c-bg: #5e333c; --c-ink: #f3e6de; }
.wqb-cover--slate  { --c-bg: #415163; --c-ink: #eef1f3; }
.wqb-cover--sand   { --c-bg: #ddcdab; --c-ink: #3a2f20; }
.wqb-cover-cat { font-size: .62em; font-weight: 500; opacity: .7; margin-bottom: .5em; }
.wqb-cover-title { font-weight: 700; font-size: 1em; line-height: 1.35; letter-spacing: -.02em; }
.wqb-cover-author { margin-top: auto; font-size: .66em; opacity: .75; }
.wqb-cover--md { font-size: 14px; }
.wqb-cover--lg { font-size: 20px; }
.wqb-cover--sm { width: 34px; flex-shrink: 0; padding: 0; }

/* ---------- 서가 ---------- */
.wqb-masthead { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px 32px; flex-wrap: wrap; padding: 16px 0 24px; margin-bottom: 28px; border-bottom: 1px solid var(--wqb-rule); }
.wqb .wqb-masthead h1 { font-size: 26px; font-weight: 700; letter-spacing: -.03em; margin-bottom: 4px; }
.wqb-masthead p { margin: 0; font-size: 14.5px; color: var(--wqb-muted); }
.wqb-search { position: relative; flex: 0 1 340px; display: flex; align-items: center; }
.wqb-search svg { position: absolute; left: 12px; color: var(--wqb-dim); pointer-events: none; }
html .wqb .wqb-search input { width: 100%; height: 42px; padding: 0 14px 0 38px; border: 1px solid var(--wqb-rule); border-radius: 10px; background: var(--wqb-surface); color: var(--wqb-ink); font: 400 14px var(--wqb-sans); }
html .wqb .wqb-search input:focus { outline: none; border-color: var(--wqb-accent); }

.wqb-home { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 40px; align-items: start; }
.wqb-home-main { min-width: 0; }
.wqb-home-side { display: grid; gap: 14px; position: sticky; top: calc(var(--top-header-height, 64px) + 16px); }

.wqb-section { margin: 0 0 40px; }
.wqb-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.wqb .wqb-section-head .wqb-h2 { margin: 0; }
.wqb .wqb-more { font-size: 13px; color: var(--wqb-muted); }
.wqb .wqb-more:hover { color: var(--wqb-ink); }

.wqb-tabs { display: flex; gap: 2px; margin: 0 0 26px; border-bottom: 1px solid var(--wqb-rule); overflow-x: auto; scrollbar-width: none; }
.wqb .wqb-tabs a { padding: 10px 14px; font-size: 14px; color: var(--wqb-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.wqb .wqb-tabs a:hover { color: var(--wqb-ink); }
.wqb .wqb-tabs a[aria-current] { color: var(--wqb-ink); font-weight: 600; border-bottom-color: var(--wqb-accent); }

/* 한 줄 서가 — 가로로 넘겨 본다 */
.wqb-row { list-style: none; margin: 0; padding: 4px 2px 12px; display: grid; grid-auto-flow: column; grid-auto-columns: 140px; gap: 22px; overflow-x: auto; scrollbar-width: thin; scroll-snap-type: x proximity; }
.wqb-row > li { scroll-snap-align: start; }
.wqb-row--wrap { grid-auto-flow: row; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); overflow: visible; gap: 30px 22px; }
.wqb-shelf-item { display: flex; flex-direction: column; gap: 3px; }
.wqb-shelf-item .wqb-cover { margin-bottom: 9px; transition: transform .2s ease, box-shadow .2s ease; }
.wqb-shelf-item:hover .wqb-cover { transform: translateY(-3px); box-shadow: 0 1px 2px rgba(0,0,0,.25), 0 14px 24px -10px rgba(0,0,0,.6); }
.wqb-shelf-title { font-size: 14.5px; font-weight: 600; line-height: 1.45; color: var(--wqb-ink); }
.wqb-shelf-item .wqb-meta { font-size: 12.5px; }

.wqb-hitlist { list-style: none; margin: 16px 0 0; padding: 0; border-top: 1px solid var(--wqb-rule); }
.wqb .wqb-hitlist a { display: flex; justify-content: space-between; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--wqb-rule); font-size: 14.5px; }
.wqb-hitlist span { color: var(--wqb-muted); font-size: 13px; white-space: nowrap; }
.wqb .wqb-hitlist a:hover strong { color: var(--wqb-accent); }

.wqb-box { padding: 16px; border: 1px solid var(--wqb-rule); border-radius: 10px; }
.wqb .wqb-box-title { font-size: 13.5px; font-weight: 700; margin: 0 0 10px; }
.wqb-box-stat { margin: 0 0 6px; font-size: 14px; color: var(--wqb-muted); }
.wqb-box-stat strong { font-size: 20px; color: var(--wqb-ink); }
.wqb-box .wqb-help { margin-bottom: 12px; }
.wqb .wqb-btn--block { display: flex; width: 100%; }
.wqb-linklist, .wqb-changes { list-style: none; margin: 0; padding: 0; }
.wqb-linklist li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; font-size: 13.5px; }
.wqb-linklist span { color: var(--wqb-dim); font-size: 12.5px; }
.wqb .wqb-linklist a:hover, .wqb .wqb-changes a:hover { color: var(--wqb-accent); text-decoration: underline; }
.wqb-changes li { padding: 7px 0; border-top: 1px solid var(--wqb-rule); font-size: 13.5px; line-height: 1.45; }
.wqb-changes li:first-child { border-top: 0; padding-top: 0; }
.wqb-changes a { display: block; }
.wqb-changes span { display: block; margin-top: 2px; font-size: 12px; color: var(--wqb-dim); }

.wqb-resume { margin: 0 0 32px; }
.wqb-resume-list { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; }
.wqb .wqb-resume-card { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; min-width: 250px; max-width: 320px; padding: 10px 14px 10px 10px; border-radius: 10px; background: var(--wqb-surface); }
.wqb .wqb-resume-card:hover { background: var(--wqb-surface-2); }
.wqb-resume-card .wqb-cover { width: 34px; padding: 0; }
.wqb-resume-card strong { display: block; font-size: 14px; line-height: 1.4; }
.wqb-resume-card span { display: block; font-size: 12.5px; color: var(--wqb-muted); margin-top: 2px; }
.wqb-resume-bar { height: 3px; margin-top: 8px; border-radius: 3px; background: var(--wqb-rule); overflow: hidden; }
.wqb-resume-bar i { display: block; height: 100%; background: var(--wqb-accent); }

.wqb-drafts { list-style: none; margin: 0; padding: 0; }
.wqb-empty { padding: 40px 20px; text-align: center; border-radius: 12px; background: var(--wqb-surface); color: var(--wqb-muted); }
.wqb-empty p { margin: 0 0 14px; }
.wqb-empty p:last-child { margin: 0; }

/* ---------- 책 소개 ---------- */
.wqb-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--wqb-dim); }
.wqb .wqb-crumbs a:hover { color: var(--wqb-ink); text-decoration: underline; }
.wqb-bar.wqb-crumbs { padding: 4px 0 8px; justify-content: flex-start; }
.wqb-book { display: grid; grid-template-columns: 210px minmax(0, 1fr) 260px; gap: 36px; padding: 20px 0 36px; align-items: start; }
.wqb-book-cover .wqb-cover { font-size: 19px; }
.wqb .wqb-book-title { font-size: clamp(24px, 3vw, 32px); font-weight: 700; line-height: 1.35; letter-spacing: -.03em; margin-bottom: 6px; }
.wqb-book-sub { margin: 0 0 8px; font-size: 16px; color: var(--wqb-soft); }
.wqb-book-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.wqb-book-summary { max-width: 620px; margin: 22px 0 0; font-size: 15px; line-height: 1.85; color: var(--wqb-soft); }
.wqb-book-summary p { margin: 0 0 10px; }

/* 위키 정보 상자 */
.wqb-infobox { width: 100%; border-collapse: collapse; font-size: 13px; border-top: 2px solid var(--wqb-rule); border-bottom: 1px solid var(--wqb-rule); }
html .wqb .wqb-infobox :is(th, td) { background: transparent !important; border-left: 0; border-right: 0; }
/* dark-mode.css 의 html.dark th {… !important} 를 북스 표에서만 되돌린다. */
html .wqb .wqb-infobox th { color: var(--wqb-muted) !important; border-color: var(--wqb-rule) !important; }
html .wqb .wqb-table-wrap th { background: transparent !important; color: var(--r-ink) !important; border-color: var(--r-ink) !important; }
.wqb-infobox caption { caption-side: top; text-align: left; padding: 0 0 8px; font-weight: 700; font-size: 13.5px; color: var(--wqb-ink); }
.wqb-infobox th { width: 84px; padding: 10px 12px 10px 2px; text-align: left; font-weight: 500; color: var(--wqb-muted); vertical-align: top; border-top: 1px solid var(--wqb-rule); }
.wqb-infobox td { padding: 10px 12px 10px 0; color: var(--wqb-ink); border-top: 1px solid var(--wqb-rule); line-height: 1.5; }
.wqb-infobox tr:first-child :is(th, td) { border-top: 0; }
.wqb .wqb-infobox a { color: var(--wqb-accent); }
.wqb-infobox .wqb-meta { font-size: 12px; }

.wqb-contents { max-width: 820px; }
.wqb .wqb-contents-title { font-size: 18px; font-weight: 700; padding-bottom: 10px; margin-bottom: 4px; border-bottom: 1px solid var(--wqb-rule); }
.wqb-toc-list { list-style: none; margin: 0; padding: 0; }
.wqb-toc-list > li { padding: 14px 0; border-bottom: 1px solid var(--wqb-rule); }
.wqb .wqb-toc-chapter { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; align-items: baseline; }
.wqb .wqb-toc-chapter:hover strong { color: var(--wqb-accent); }
.wqb-toc-num { font-size: 15px; font-weight: 700; color: var(--wqb-accent); font-variant-numeric: tabular-nums; }
.wqb-toc-text strong { display: block; font-size: 16px; font-weight: 600; line-height: 1.5; transition: color .15s ease; }
.wqb-toc-text span { display: block; margin-top: 1px; font-size: 13px; color: var(--wqb-muted); line-height: 1.6; }
.wqb-toc-time { font-size: 12.5px; color: var(--wqb-dim); white-space: nowrap; }
.wqb-toc-read { display: none; margin-left: 8px; color: var(--wqb-accent); font-style: normal; }
.is-read .wqb-toc-read { display: inline; }
.wqb-toc-sections { list-style: none; margin: 6px 0 0 40px; padding: 0; display: flex; flex-wrap: wrap; gap: 2px 18px; }
.wqb .wqb-toc-sections a { font-size: 13px; color: var(--wqb-muted); }
.wqb .wqb-toc-sections a:hover { color: var(--wqb-ink); text-decoration: underline; }
.wqb-toc-sections span { color: var(--wqb-dim); margin-right: 5px; font-variant-numeric: tabular-nums; }

/* ---------- 리더 ---------- */
.wqb-reader { --r-size: 17px; --r-leading: 1.9; --r-font: var(--wqb-sans); }
html[data-wqb-theme="sepia"] body.wqb-reading .wqb {
    --r-bg: #f3ebdc; --r-ink: #3a3125; --r-soft: #4b4134; --r-muted: #7b6d5a; --r-rule: #e0d4bf;
    --r-accent: #8a6a3d; --r-surface: #ebe1cd; --r-mark: rgba(214, 176, 100, .32); --r-code: #e7dcc6;
}
html[data-wqb-theme="paper"] body.wqb-reading .wqb {
    --r-bg: #fbfaf7; --r-ink: #24221e; --r-soft: #3c3a34; --r-muted: #6f6a60; --r-rule: #e8e4dc;
    --r-accent: #86683f; --r-surface: #f2efe9; --r-mark: rgba(240, 205, 120, .45); --r-code: #f1eee8;
}
html[data-wqb-theme="sepia"] body.wqb-reading { background: #f3ebdc !important; }
html[data-wqb-theme="paper"] body.wqb-reading { background: #fbfaf7 !important; }
html[data-wqb-theme] body.wqb-reading .wqb {
    color: var(--r-ink);
    --wqb-ink: var(--r-ink); --wqb-soft: var(--r-soft); --wqb-muted: var(--r-muted); --wqb-dim: var(--r-muted);
    --wqb-rule: var(--r-rule); --wqb-accent: var(--r-accent); --wqb-surface: var(--r-surface);
}
.wqb-reader[data-font="serif"] { --r-font: var(--wqb-serif); }
.wqb-reader[data-leading="snug"] { --r-leading: 1.7; }
.wqb-reader[data-leading="loose"] { --r-leading: 2.15; }

.wqb-progress { position: fixed; left: 0; right: 0; top: 0; height: 2px; z-index: 60; pointer-events: none; }
.wqb-progress span { display: block; height: 100%; width: 0; background: var(--wqb-accent); }

.wqb-toolbar {
    position: sticky; top: var(--top-header-height, 64px); z-index: 45;
    display: flex; align-items: center; gap: 8px; padding: 8px 0;
    background: var(--r-bg); border-bottom: 1px solid var(--r-rule);
}
body:has(.top-header.hide) :is(.wqb-toolbar, .wqb-editor-toolbar) { top: 0; }
.wqb-tool {
    display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 10px;
    border: 0; border-radius: 8px; background: none; color: var(--r-ink);
    font: 500 14px var(--wqb-sans); cursor: pointer;
}
.wqb-tool:hover, .wqb-tool[aria-expanded="true"] { background: var(--r-surface); }
.wqb-tool-aa { font-weight: 600; font-size: 15px; }
.wqb-tool-aa small { font-size: 11px; }
.wqb-toolbar .wqb-crumbs { flex: 1; min-width: 0; flex-wrap: nowrap; white-space: nowrap; overflow: hidden; color: var(--r-muted); }
.wqb-toolbar .wqb-crumbs > * { overflow: hidden; text-overflow: ellipsis; }
.wqb-toolbar-pos { font-size: 13px; color: var(--r-muted); font-variant-numeric: tabular-nums; }

.wqb-settings {
    position: fixed; z-index: 1050; top: 70px;
    right: max(16px, calc(50vw - 540px)); width: min(340px, calc(100vw - 32px)); padding: 16px;
    border: 1px solid var(--r-rule); border-radius: 12px;
    background: var(--r-surface); box-shadow: 0 12px 32px -12px rgba(0, 0, 0, .45);
    display: grid; gap: 12px;
}
.wqb-setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--r-muted); }
.wqb-seg { display: inline-flex; border-radius: 8px; padding: 2px; gap: 2px; background: var(--r-bg); }
.wqb-seg button, .wqb-seg output {
    min-height: 30px; padding: 0 10px; border: 0; border-radius: 6px; background: none;
    color: var(--r-ink); font: 500 13px var(--wqb-sans); cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
}
.wqb-seg output { cursor: default; min-width: 48px; justify-content: center; color: var(--r-muted); }
.wqb-seg button[aria-checked="true"] { background: var(--r-ink); color: var(--r-bg); }
.wqb-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 1px solid rgba(128, 128, 128, .5); }
.wqb-swatch--night { background: #191a18; } .wqb-swatch--sepia { background: #f3ebdc; } .wqb-swatch--paper { background: #fbfaf7; }

/* 왼쪽 책 내비게이션 — 데스크톱: 고정 사이드바, 모바일: 서랍 */
.wqb-drawer { display: flex; flex-direction: column; position: sticky; top: calc(var(--top-header-height, 64px) + 66px); max-height: calc(100vh - var(--top-header-height, 64px) - 82px); align-self: start; padding-top: 28px; }
.wqb-drawer-head { display: flex; gap: 10px; align-items: center; padding: 0 0 14px; margin-bottom: 6px; border-bottom: 1px solid var(--r-rule); }
.wqb .wqb-drawer-book { flex: 1; min-width: 0; display: flex; gap: 10px; align-items: center; }
.wqb-drawer-book > span { min-width: 0; }
.wqb .wqb-drawer-title { display: block; font-weight: 700; font-size: 14px; line-height: 1.4; color: var(--r-ink); }
.wqb-drawer-head .wqb-meta { display: block; color: var(--r-muted); font-size: 12px; }
.wqb-drawer-close { display: none !important; color: var(--r-muted); }
.wqb-drawer-list { list-style: none; margin: 0; padding: 4px 0; overflow-y: auto; flex: 1; scrollbar-width: thin; }
.wqb .wqb-drawer-list > li > a { display: flex; gap: 8px; align-items: baseline; padding: 7px 8px; border-radius: 6px; font-size: 13.5px; line-height: 1.5; color: var(--r-soft); }
.wqb-drawer-list > li > a > span { color: var(--r-muted); min-width: 14px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.wqb .wqb-drawer-list > li > a:hover { background: var(--r-surface); }
.wqb .wqb-drawer-list > li > a[aria-current] { background: var(--r-surface); color: var(--r-ink); font-weight: 600; }
.wqb-drawer-list .wqb-toc-read { margin-left: auto; }
.wqb-drawer-sections { list-style: none; margin: 2px 0 6px 22px; padding: 0 0 0 10px; border-left: 1px solid var(--r-rule); }
.wqb .wqb-drawer-sections a { display: block; padding: 4px 6px; font-size: 12.5px; line-height: 1.45; color: var(--r-muted); border-left: 2px solid transparent; margin-left: -11px; padding-left: 15px; }
.wqb .wqb-drawer-sections a:hover { color: var(--r-ink); }
.wqb .wqb-drawer-sections a.is-active { color: var(--r-ink); border-left-color: var(--r-accent); }
.wqb-drawer-foot { display: flex; gap: 14px; padding: 12px 8px 0; margin-top: 6px; border-top: 1px solid var(--r-rule); font-size: 12.5px; }
.wqb .wqb-drawer-foot a { color: var(--r-muted); }
.wqb .wqb-drawer-foot a:hover { color: var(--r-ink); text-decoration: underline; }
.wqb-scrim { position: fixed; inset: 0; z-index: 1099; background: rgba(0, 0, 0, .4); }
.wqb-tool--toc { display: none; }

.wqb-reader-grid { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 44px; }
.wqb-chapter { width: 100%; max-width: 720px; padding: 18px 0 0; color: var(--r-ink); }

/* 위키식 문서 탭 */
.wqb-pagetabs { display: flex; gap: 2px; margin-bottom: 24px; border-bottom: 1px solid var(--r-rule, var(--wqb-rule)); }
.wqb .wqb-pagetabs a { padding: 8px 14px; font-size: 13.5px; color: var(--r-muted, var(--wqb-muted)); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.wqb .wqb-pagetabs a:hover { color: var(--r-ink, var(--wqb-ink)); }
.wqb .wqb-pagetabs a[aria-current] { color: var(--r-ink, var(--wqb-ink)); font-weight: 600; border-bottom-color: var(--r-accent, var(--wqb-accent)); }

.wqb-chapter-head { margin-bottom: 26px; }
.wqb-chapter-no { margin: 0 0 6px; font-size: 13px; color: var(--r-muted); }
.wqb .wqb-chapter-head h1 { font-size: clamp(25px, 3vw, 32px); font-weight: 700; line-height: 1.38; letter-spacing: -.03em; color: var(--r-ink); margin: 0 0 8px; }
.wqb-chapter-lead { margin: 0 0 8px; font-size: 16px; line-height: 1.7; color: var(--r-soft); }
.wqb-chapter-head .wqb-meta { color: var(--r-muted); }

/* 위키식 본문 목차 상자 */
.wqb-inline-toc { display: inline-block; min-width: 240px; max-width: 100%; margin: 0 0 28px; padding: 14px 20px 14px 16px; border: 1px solid var(--r-rule); border-radius: 8px; background: var(--r-surface); }
.wqb-inline-toc > p { margin: 0 0 6px; font-size: 13px; font-weight: 700; color: var(--r-ink); }
.wqb-inline-toc ol { list-style: none; margin: 0; padding: 0; }
.wqb .wqb-inline-toc a { display: block; padding: 2px 0; font-size: 14px; color: var(--r-accent); }
.wqb .wqb-inline-toc a:hover { text-decoration: underline; }
.wqb-inline-toc span { display: inline-block; min-width: 20px; color: var(--r-muted); font-variant-numeric: tabular-nums; }

.wqb-prose { font-family: var(--r-font); font-size: var(--r-size); line-height: var(--r-leading); color: var(--r-ink); }
.wqb-prose > :first-child { margin-top: 0; }
.wqb-prose p { margin: 0 0 1.1em; }
html .wqb .wqb-prose :is(h2, h3, h4) { font-family: var(--wqb-sans); color: var(--r-ink); letter-spacing: -.02em; scroll-margin-top: calc(var(--top-header-height, 64px) + 64px); }
.wqb .wqb-prose h2 { font-size: 1.32em; font-weight: 700; line-height: 1.45; margin: 2.2em 0 .8em; padding-bottom: .35em; border-bottom: 1px solid var(--r-rule); }
.wqb .wqb-prose h3 { font-size: 1.08em; font-weight: 700; line-height: 1.5; margin: 1.8em 0 .5em; }
.wqb .wqb-prose h4 { font-size: 1em; font-weight: 600; margin: 1.5em 0 .4em; color: var(--r-soft); }
.wqb-prose strong { font-weight: 700; }
.wqb-prose mark { background: var(--r-mark); color: inherit; padding: 0 .1em; border-radius: 2px; }
.wqb-prose del { color: var(--r-muted); }
.wqb .wqb-prose a { color: var(--r-accent); text-decoration: underline; text-underline-offset: 3px; }
/* 나눔고딕코딩은 한글을 정확히 영문 두 칸 폭으로 그려 pandas 출력 표의 열이 맞는다. */
.wqb-prose code { font-family: 'Nanum Gothic Coding', ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-variant-ligatures: none; font-feature-settings: 'liga' 0, 'calt' 0; font-size: .86em; padding: .1em .35em; border-radius: 4px; background: var(--r-code); }
.wqb-prose ul, .wqb-prose ol { margin: 0 0 1.1em; padding-left: 1.3em; }
.wqb-prose li { margin: .3em 0; }
.wqb-prose li::marker { color: var(--r-muted); }
.wqb-prose blockquote { margin: 1.2em 0; padding: .1em 0 .1em 1em; border-left: 3px solid var(--r-rule); color: var(--r-soft); }
.wqb-prose blockquote p { margin-bottom: .3em; }
.wqb-prose blockquote p:last-child { margin-bottom: 0; }
.wqb-prose hr { border: 0; border-top: 1px solid var(--r-rule); margin: 2.2em 0; }
.wqb-prose .wqb-figure { margin: 1.8em 0; }
.wqb-prose .wqb-figure img { display: block; max-width: 100%; height: auto; margin: 0 auto; border-radius: 6px; }
.wqb-prose figcaption { margin-top: .6em; text-align: center; font-size: .78em; color: var(--r-muted); }
.wqb-code { position: relative; margin: 1.4em 0; padding: 30px 16px 14px; border-radius: 8px; background: var(--r-code); overflow-x: auto; font-size: .82em; line-height: 1.7; }
.wqb-code code { padding: 0; background: none; font-size: 1em; white-space: pre; }
.wqb-code-lang { position: absolute; top: 8px; left: 16px; font-family: var(--wqb-sans); font-size: 11px; color: var(--r-muted); }
.wqb-table-wrap { margin: 1.4em 0; overflow-x: auto; }
.wqb-table-wrap table { width: 100%; border-collapse: collapse; font-family: var(--wqb-sans); font-size: .82em; line-height: 1.6; }
.wqb-table-wrap th { text-align: left; font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--r-ink); white-space: nowrap; }
.wqb-table-wrap td { padding: 10px 12px; border-bottom: 1px solid var(--r-rule); vertical-align: top; }

.wqb-callout { --co: var(--r-accent); margin: 1.4em 0; padding: 14px 16px; border-radius: 8px; background: var(--r-surface); font-size: .94em; }
.wqb-callout p:last-child { margin-bottom: 0; }
.wqb .wqb-callout-title { display: flex; align-items: baseline; gap: 8px; margin: 0 0 .4em; font-family: var(--wqb-sans); font-weight: 700; font-size: .9em; }
.wqb-callout-title span { font-size: .85em; font-weight: 600; color: var(--co); }
.wqb-callout--tip { --co: #7ea88a; }
.wqb-callout--note { --co: #8aa3bb; }
.wqb-callout--warning { --co: #c99467; }

/* 접는 정답 */
.wqb-answer { margin: 1em 0 1.6em; border: 1px solid var(--r-rule); border-radius: 8px; }
.wqb-answer > summary { cursor: pointer; padding: 10px 14px; font-family: var(--wqb-sans); font-size: .86em; font-weight: 600; color: var(--r-accent); list-style: none; display: flex; align-items: center; gap: 6px; min-height: 44px; }
.wqb-answer > summary::-webkit-details-marker { display: none; }
.wqb-answer > summary::before { content: '▸'; transition: transform .15s ease; }
.wqb-answer[open] > summary::before { transform: rotate(90deg); }
.wqb-answer[open] > summary { border-bottom: 1px solid var(--r-rule); }
.wqb-answer-body { padding: 4px 14px 12px; }
.wqb-answer-body .wqb-code { margin: .8em 0; }
.wqb-answer-body p { margin: .6em 0; font-size: .95em; color: var(--r-soft); }

.wqb-chapter-end { margin-top: 48px; display: grid; gap: 22px; }
.wqb-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.wqb .wqb-pager-card { display: block; padding: 14px 16px; border: 1px solid var(--r-rule); border-radius: 10px; }
.wqb .wqb-pager-card:hover { background: var(--r-surface); }
.wqb-pager-card span { display: block; font-size: 12.5px; color: var(--r-muted); margin-bottom: 3px; }
.wqb-pager-card strong { display: block; font-size: 15px; line-height: 1.45; color: var(--r-ink); }
.wqb-pager-card--next { text-align: right; }
.wqb-docfoot { padding: 14px 16px; border-radius: 10px; background: var(--r-surface); font-size: 12.5px; color: var(--r-muted); line-height: 1.7; }
.wqb-docfoot p { margin: 0; }
.wqb-docfoot-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px !important; }
.wqb-docfoot-tags span { font-weight: 600; color: var(--r-soft); margin-right: 2px; }
.wqb .wqb-docfoot-tags a { padding: 1px 8px; border-radius: 5px; border: 1px solid var(--r-rule); color: var(--r-soft); }
.wqb .wqb-docfoot-tags a:hover { color: var(--r-ink); }
.wqb-docfoot-links { display: flex; gap: 14px; margin-top: 8px !important; }
.wqb .wqb-docfoot-links a { color: var(--r-accent); }
.wqb .wqb-docfoot-links a:hover { text-decoration: underline; }

/* ---------- 집필 ---------- */
.wqb-studio { padding: 12px 0 0; }
.wqb-studio-head { margin-bottom: 24px; }
.wqb .wqb-studio-head h1 { font-size: 24px; font-weight: 700; letter-spacing: -.03em; margin-bottom: 6px; }
.wqb .wqb-studio-head .wqb-meta a { color: var(--wqb-accent); }
.wqb-studio-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 40px; align-items: start; }
.wqb-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--wqb-dim); margin-right: 6px; vertical-align: middle; }
.wqb-dot--live { background: #7fb38a; }

.wqb-form { display: grid; gap: 20px; }
.wqb-field { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.wqb-field label, .wqb-field legend { font-size: 13.5px; font-weight: 600; color: var(--wqb-soft); padding: 0; }
.wqb-field legend { margin-bottom: 8px; }
.wqb-req { color: var(--wqb-accent); }
html .wqb .wqb-field :is(input[type=text], input[type=number], input:not([type]), textarea, select),
html .wqb .wqb-editor-foot input {
    width: 100%; padding: 11px 12px; border: 1px solid var(--wqb-rule); border-radius: 8px;
    background: var(--wqb-surface); color: var(--wqb-ink); font: 400 15px/1.6 var(--wqb-sans);
}
html .wqb :is(.wqb-field, .wqb-editor-foot) :is(input, textarea, select):focus { outline: none; border-color: var(--wqb-accent); }
.wqb-help { margin: 0; font-size: 12.5px; color: var(--wqb-dim); line-height: 1.6; }
.wqb-error, .wqb-form-error { margin: 0; font-size: 13px; color: #e0a196; }
.wqb-form-error ul { margin: 0; padding-left: 18px; }
.wqb-form-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 4px; }

.wqb-tones { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.wqb .wqb-tone { position: relative; display: grid; place-items: end start; aspect-ratio: 3 / 4; padding: 8px; border-radius: 6px; background: var(--c-bg); color: var(--c-ink); font-size: 12px; font-weight: 500; cursor: pointer; }
.wqb-tone input { position: absolute; opacity: 0; pointer-events: none; }
.wqb-tone:has(input:checked) { outline: 2px solid var(--wqb-ink); outline-offset: 2px; }
.wqb-tone:has(input:focus-visible) { outline: 2px dashed var(--wqb-accent); outline-offset: 2px; }

.wqb-studio-side { display: grid; gap: 16px; position: sticky; top: calc(var(--top-header-height, 64px) + 16px); }
.wqb-studio-preview { display: flex; justify-content: center; padding: 24px; border-radius: 12px; background: var(--wqb-surface); }
.wqb-studio-preview .wqb-cover { width: 160px; font-size: 16px; }
.wqb-panel { padding: 18px; border-radius: 12px; border: 1px solid var(--wqb-rule); }
.wqb .wqb-panel h2 { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.wqb-panel form { display: flex; flex-wrap: wrap; gap: 8px; }
.wqb-panel .wqb-help { flex-basis: 100%; margin-bottom: 4px; }
.wqb-panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.wqb .wqb-panel-head h2 { margin: 0; }
.wqb-chapter-admin { list-style: none; margin: 0; padding: 0; }
.wqb-chapter-admin li { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 9px 0; border-top: 1px solid var(--wqb-rule); }
.wqb .wqb-chapter-admin-title { font-size: 14px; line-height: 1.45; }
.wqb .wqb-chapter-admin-title:hover { color: var(--wqb-accent); }
.wqb-chapter-admin-title small { display: block; font-size: 11.5px; color: var(--wqb-dim); }
.wqb-reorder { display: flex !important; gap: 2px !important; }
.wqb-reorder button { width: 26px; height: 26px; border: 1px solid var(--wqb-rule); border-radius: 6px; background: none; color: var(--wqb-muted); cursor: pointer; }
.wqb-reorder button:hover:not([disabled]) { color: var(--wqb-ink); }
.wqb-reorder button[disabled] { opacity: .3; cursor: default; }
.wqb-steps { margin: 0; padding-left: 18px; color: var(--wqb-muted); font-size: 13.5px; line-height: 1.9; }

.wqb-editing .wqb { padding-bottom: 24px; }
.wqb-editor { padding-top: 12px; }
.wqb-editor-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 14px; }
.wqb-editor-head > div:first-child { flex: 1; min-width: 0; }
html .wqb :is(.wqb-editor-title, .wqb-editor-summary) { display: block; width: 100%; border: 0; background: none; color: var(--wqb-ink); padding: 0; }
html .wqb .wqb-editor-title { font: 700 clamp(22px, 2.6vw, 28px)/1.4 var(--wqb-sans); letter-spacing: -.03em; margin-bottom: 4px; }
html .wqb .wqb-editor-summary { font: 400 15px/1.6 var(--wqb-sans); color: var(--wqb-soft); }
.wqb-editor-title:focus, .wqb-editor-summary:focus { outline: none; }
.wqb-editor-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.wqb-editor-toolbar {
    position: sticky; top: var(--top-header-height, 64px); z-index: 45;
    display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 6px; margin-bottom: 10px;
    border-radius: 10px; background: var(--wqb-surface);
}
.wqb-editor-toolbar button { min-height: 32px; padding: 0 9px; border: 0; border-radius: 6px; background: none; color: var(--wqb-soft); font: 500 13px var(--wqb-sans); cursor: pointer; }
.wqb-editor-toolbar button:hover { background: var(--wqb-surface-2); color: var(--wqb-ink); }
.wqb-editor-toolbar mark { background: var(--r-mark); color: inherit; }
.wqb-sep { width: 1px; height: 18px; background: var(--wqb-rule); margin: 0 4px; }
.wqb-editor-tabs { margin-left: auto; display: none; border-radius: 8px; padding: 2px; background: var(--wqb-bg); }
.wqb-editor-tabs button[aria-selected="true"] { background: var(--wqb-ink); color: var(--wqb-bg); }
.wqb-editor-panes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; min-height: 60vh; }
html .wqb .wqb-editor-write textarea {
    width: 100%; height: 100%; min-height: 60vh; resize: vertical; padding: 18px;
    border: 1px solid var(--wqb-rule); border-radius: 10px; background: var(--wqb-surface); color: var(--wqb-ink);
    font: 400 14px/1.8 ui-monospace, 'SF Mono', Menlo, Consolas, 'Noto Sans KR', monospace; tab-size: 2;
}
html .wqb .wqb-editor-write textarea:focus { outline: none; border-color: var(--wqb-accent); }
.wqb-editor-preview { border: 1px solid var(--wqb-rule); border-radius: 10px; padding: 0 24px 24px; max-height: 80vh; overflow-y: auto; background: var(--r-bg); }
.wqb-reader-surface { --r-size: 16px; --r-leading: 1.85; --r-font: var(--wqb-sans); }
.wqb-editor-preview .wqb-chapter { padding-top: 22px; }
.wqb-editor-preview .wqb-chapter-head { margin-bottom: 20px; }
.wqb-editor-foot { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 14px 20px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--wqb-rule); }
.wqb-field--inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wqb-field--inline label { white-space: nowrap; font-size: 13px; }
html .wqb .wqb-field--inline input { width: 240px; padding: 8px 10px; font-size: 14px; }
.wqb-slug-prefix { font-size: 13px; color: var(--wqb-dim); margin-right: -4px; }
.wqb-cheatsheet { flex-basis: 100%; font-size: 13px; color: var(--wqb-muted); }
.wqb-cheatsheet summary { cursor: pointer; color: var(--wqb-soft); min-height: 34px; display: flex; align-items: center; }
.wqb-cheatsheet dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px 20px; margin: 6px 0 0; }
.wqb-cheatsheet dd { margin: 0; color: var(--wqb-dim); font-size: 12.5px; }
.wqb-cheatsheet code { font-size: 12.5px; padding: 1px 5px; border-radius: 4px; background: var(--wqb-surface-2); color: var(--wqb-ink); }
.wqb-editor-foot .wqb-btn--danger { margin-left: auto; }

.wqb-history { list-style: none; margin: 0; padding: 0; max-width: 720px; }
.wqb-history li { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--wqb-rule); }
.wqb-history-dot { display: none; }
.wqb-history-body { flex: 1; min-width: 0; }
.wqb-history-body p { margin: 0 0 2px; font-size: 14px; }
.wqb-history .wqb-badge { margin: 0 0 0 6px; font-size: 11px; padding: 1px 6px; }

/* ---------- 반응형 ---------- */
@media (max-width: 1000px) {
    .wqb-home { grid-template-columns: minmax(0, 1fr); }
    .wqb-home-side { position: static; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
    .wqb-book { grid-template-columns: 180px minmax(0, 1fr); }
    .wqb-infobox { grid-column: 1 / -1; max-width: 520px; }
    .wqb-reader-grid { grid-template-columns: minmax(0, 1fr); }
    .wqb-chapter { margin: 0 auto; }
    .wqb-tool--toc { display: inline-flex; }
    .wqb-drawer {
        display: none; position: fixed; z-index: 1100; inset: 0 auto 0 0; top: 0; max-height: none;
        width: min(320px, 86vw); height: 100dvh; align-self: stretch; padding: 18px 14px; background: var(--r-surface); border-right: 1px solid var(--r-rule);
    }
    .wqb-drawer.is-open { display: flex; }
    .wqb-drawer-close { display: inline-flex !important; }
    .wqb .wqb-drawer-list > li > a:hover, .wqb .wqb-drawer-list > li > a[aria-current] { background: var(--r-bg); }
}
@media (max-width: 760px) {
    .wqb-masthead { padding: 8px 0 18px; margin-bottom: 20px; }
    .wqb-search { flex-basis: 100%; }
    .wqb-row { grid-auto-columns: 116px; gap: 14px; }
    .wqb-row--wrap { grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); }
    .wqb-cover--md { font-size: 12.5px; }
    .wqb-book { grid-template-columns: 116px minmax(0, 1fr); gap: 18px; padding-top: 12px; }
    .wqb-book-cover .wqb-cover { font-size: 12px; }
    .wqb-book-summary { grid-column: 1 / -1; }
    .wqb-toc-sections { margin-left: 40px; }
    .wqb-pager { grid-template-columns: minmax(0, 1fr); }
    .wqb-pager-card--next { text-align: left; }
    .wqb-studio-grid { grid-template-columns: minmax(0, 1fr); }
    .wqb-studio-side { position: static; order: -1; }
    .wqb-studio-preview .wqb-cover { width: 120px; font-size: 13px; }
    .wqb-editor-tabs { display: inline-flex; }
    .wqb-editor-panes { grid-template-columns: minmax(0, 1fr); }
    .wqb-editor-panes[data-pane="write"] .wqb-editor-preview { display: none; }
    .wqb-editor-panes[data-pane="preview"] .wqb-editor-write { display: none; }
    .wqb-tool span:not(.wqb-tool-aa) { display: none; }
    .wqb-chapter { padding-top: 24px; }
    .wqb-editor-head { flex-direction: column; gap: 10px; }
    .wqb-editor-actions { width: 100%; justify-content: space-between; }
    .wqb-editor-preview { padding: 0 16px 18px; }
    html .wqb .wqb-field--inline input { width: 100%; }
    .wqb-tones { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .wqb-editor-foot .wqb-btn--danger { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .wqb *, .wqb *::before, .wqb *::after { transition: none !important; animation: none !important; }
}
