/* =============== THEME VARS =============== */
:root{
    --app-font: "Noto Sans", "Noto Sans KR", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --bg:#f7f8fa;
    --bg-primary: #1d1d1d;
    /*--panel:#ffffff;*/
    --panel: #fcfcfc;
    --text:#111827;
    --muted:#6b7280;
    --accent:#2563eb;
    /*--border:#e5e7eb;*/
    --border: #d7d7d7;
    --border-weak:#d1d5db;
    --elev-shadow:0 8px 24px rgba(0,0,0,.08);

    /* 추가 토큰: 라이트 */
    --panel-subtle: color-mix(in oklab, var(--panel), black 4%);
    --panel-subtle-strong: color-mix(in oklab, var(--panel), black 6%);
    --hover-tint:#f3f6ff;

    /* 북마크 안전 영역(px) */
    --bm-safe: 48px;


    --panel-btn-size: 32px;   /* 버튼 박스 */
    --panel-ico-size: 18px;   /* 아이콘 실제 크기 */


    --rp-panel: var(--panel, #fff);
    --rp-text:  var(--text, #111827);
    --rp-border: var(--border, #e5e7eb);
    --rp-accent: var(--accent, #2563eb);
    --rp-shadow: var(--elev-shadow, 0 12px 32px rgba(0,0,0,.18));

    --font-xs: 10px;
    --font-sm: 12px;
    --font-md: 14px;
    --font-lg: 16px;
    --font-xl: 18px;
    --font-2xl: 20px;
    --font-3xl: 24px;
    --font-4xl: 28px;

    --border-radius-xs: 4px;
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 16px;
    --border-radius-xl: 20px;
    --border-radius-round: 9999px;

    --primary-color-5: #EFF5FF;
    --primary-color-10: #D3E1FB;
    --primary-color-20: #A7C4F7;
    --primary-color-30: #7CA6F3;
    --primary-color-40: #5089EF;
    --primary-color-50: #246BEB;
    --primary-color-60: #1D56BC;
    --primary-color-70: #16408D;
    --primary-color-80: #0E2B5E;
    --primary-color-90: #07152F;

    --secondary-color-5: #EDF1F5;
    --secondary-color-10: #CDD7E4;
    --secondary-color-20: #B4C4D6;
    --secondary-color-30: #99B0CB;
    --secondary-color-40: #2A5C96;
    --secondary-color-50: #003675;
    --secondary-color-60: #002B5E;
    --secondary-color-70: #002046;
    --secondary-color-80: #00162F;
    --secondary-color-90: #000B17;

    --icon-color: var(--primary-color-70);

    --bg-color-stage: #f9f9f9;

    --gutter-width: 24px;       /* 접힘(스파인) 폭 */
    --fold-opacity: .12;        /* 어둠 강도(라이트) */
    --fold-fade: 8%;            /* 위아래 페이드 여백 */

    --bg-panner: #eee;

    --color-basic: #000;

    --stage-top-offset: 0px;

    --range-color: #e5e7eb;
}

/* Dark mode variables (activate via html.dark) */
html.dark{
    --bg:#0b0c0f;
    /*--panel:#121318;*/
    --panel:#2d2d2d;
    --text:#e9edf1;
    --muted:#9aa3ad;
    /*--accent:#4da3ff;*/
    --accent:#246beb;
    --border:#2a2d36;
    --border-weak:#1f2128;
    --elev-shadow:0 8px 24px rgba(0,0,0,.35);

    /* 추가 토큰: 다크 */
    --panel-subtle: color-mix(in oklab, var(--panel), white 6%);
    --panel-subtle-strong: color-mix(in oklab, var(--panel), white 8%);
    --hover-tint: rgba(77,163,255,.10);

    --icon-color: #e9edf1;

    --bg-color-stage: #444444;

    --bg-panner: #1d1d1d;

    --color-basic: #fff;


    --range-color: #cccccc;
}

/* =============== FONT COMPONENT =============== */
.font-xs {
    font-size: var(--font-xs);
}
.font-sm {
    font-size: var(--font-sm);
}
.font-md {
    font-size: var(--font-md);
}
.font-lg {
    font-size: var(--font-lg);
}
.font-xl {
    font-size: var(--font-xl);
}
.font-2xl {
    font-size: var(--font-2xl);
}
.font-3xl {
    font-size: var(--font-3xl);
}
.font-4xl {
    font-size: var(--font-4xl);
}


/* --- 1. 전역 스크롤 및 마진 제거 (iOS 스크롤 방지 필수) --- */
html, body {
    margin: 0 !important;
    padding: 0 !important;
    height: 100%;
    width: 100%;
    /* ⭐️ body에 스크롤 금지 */
    overflow: hidden !important;
}

input, button, textarea, a {
    touch-action: manipulation;
}

/* =============== BASE LAYOUT =============== */
html,body{
    height:100%;
    font-family: "Noto Sans", "Noto Sans KR", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-weight: 400;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-kerning: normal;
    font-synthesis-weight: none;
    font-synthesis-style: none;
}
body{
    margin:0;
    color:var(--text);
    background:var(--bg);
    width:100vw;
    height:100vh;
    overflow:hidden;
    display:grid;
    grid-template-rows:auto minmax(0,1fr);
    grid-template-columns:100%;
}

/* optional: hide scrollbar */
::-webkit-scrollbar{ display:none; }

/* =============== GLOBAL LOADING =============== */
#globalLoadingOverlay{
    position:fixed; inset:0;
    display:grid; place-items:center;
    opacity:0; pointer-events:none;
    transition:opacity .15s ease;
    z-index:9999;
}
#globalLoadingOverlay.show{ opacity:1; pointer-events:auto; }
#globalLoadingOverlay .glo__backdrop{
    position:absolute; inset:0;
    background:rgba(0,0,0,.14);
    backdrop-filter:blur(1.5px);
}
#globalLoadingOverlay .glo__box{
    position:relative;
    padding:16px 18px;
    border-radius: var(--border-radius-md);
    background:var(--panel);
    box-shadow:0 10px 30px rgba(0,0,0,.12);
    display:flex;
    flex-direction: column;
    align-items:center;
    justify-content: center;
    gap:12px;
    border:1px solid var(--border);
}
#globalLoadingOverlay .glo__spinner{
    width:22px; height:22px;
    border:3px solid var(--border);
    border-top-color:var(--accent);
    border-radius: var(--border-radius-round);
    animation:glo-spin .8s linear infinite;
}
#globalLoadingOverlay .glo__label{ font-size:14px; color:var(--text); }
@keyframes glo-spin{ to{ transform:rotate(360deg); } }

/* =============== HEADER =============== */
header{
    display:flex; justify-content:space-between; align-items:center;
    padding:5px 14px;
    /*background:rgba(255,255,255,.92);*/
    border-bottom:1px solid var(--border);
    background-color: #eee;
    position:sticky; top:0; z-index:10; width:100%; max-width:100vw;
    box-sizing:border-box; inset-inline:0; flex-shrink:0;
    backdrop-filter:saturate(120%) blur(4px);
}
header .controls{
    display:flex; gap:8px; align-items:center; flex-wrap:wrap;
    /*flex: 1;*/
}
header .controls-center {
    justify-content: center;
}
header .controls-right {
    justify-content: right;
}
header button, header input{
    appearance: none;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border-weak);
    border-radius: var(--border-radius-sm);
    padding: 8px 12px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    /*font-size: 11px;*/
    font-size: var(--font-sm);
}
header input {
    min-height: 36px;
    box-sizing: border-box;
    outline: none;
}

header button:hover{ border-color:var(--accent); }
.muted{ color:var(--muted); }


/* Header dark overrides */
html.dark header{
    /*background:rgba(18,19,24,.92);*/
    background-color: #1d1d1d;
    border-bottom:1px solid var(--border);
}
html.dark header button, html.dark header input{
    /*background:#1a1c23;*/
    background-color: #2d2d2d;
    color:var(--text);
    border:1px solid var(--border);
}

header button,
html.dark header button {
    padding: 0;
    background-color: transparent;
    border: none;
}

/* === Mode buttons === */
.modeBtn{
    appearance:none;
    background:var(--panel);
    color:var(--text);
    /*border:1px solid var(--border-weak);*/
    border-radius: var(--border-radius-sm);
    padding:8px 12px;
    line-height:1;
    cursor:pointer;
    display:inline-flex;
    align-items:center;
    gap:8px;
    /*transition: background .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease, filter .15s ease;*/
}
.modeBtn:hover:not(:disabled){
    background:var(--hover-tint);
    border-color:var(--accent);
}
.modeBtn:disabled{ opacity:.6; cursor:not-allowed; }
.modeBtn--active{
    background:var(--accent) !important;
    color:#fff !important;
    border-color:transparent !important;
}
.modeBtn--active svg {
    color: #fff;
}
.modeBtn--active:hover:not(:disabled){ filter:brightness(1.05); }

.pageRenderPlaceholder{ transition: opacity .12s ease; }


html header button.btn_zoomout,
html header button.btn_zoomin {
    padding: 0;
    background-color: transparent;
    border: none;
}

.btn_common {
    min-height: 36px;
}
.btn_pagemove {
    padding: 0;
    border: none !important;
}
header button svg,
header .func_keyword_search svg {
    color: var(--icon-color);
}

.modeBtnWrap {
    appearance:none;
    background:var(--panel);
    color:var(--text);
    /*border:1px solid var(--border-weak);*/
    border-radius: var(--border-radius-sm);
    padding:8px 12px;
    line-height:1;
    cursor:pointer;
    display:inline-flex;
    align-items:center;
    gap:8px;
}
header .modeBtnWrap button.modeBtn {
    height: 25px;
    border-radius: 4px;
    padding-right: 3px;
    padding-left: 3px;
}
.area_line {
    display: block;
    width: 1px;
    height: 8px;
    background-color: var(--text);
}

.input_area {
    appearance: none;
    background: var(--panel);
    color: var(--text);
    /*border: 1px solid var(--border-weak);*/
    border-radius: var(--border-radius-sm);
    padding: 8px 5px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;

    height: 41px;
    box-sizing: border-box;
}
.input_area input {
    height: 25px;
    outline: none;
    border: none;
}

.input_common {
    height: 41px;
    box-sizing: border-box;
}

.btn_hidden {
    display: none !important;
}

/* =============== THEME TOGGLE BUTTON =============== */
.theme-toggle{
    /*display:inline-flex; align-items:center; gap:8px;
    padding:8px 10px;
    border:1px solid var(--border-weak);
    border-radius: var(--border-radius-sm);*/
    /*background:#fff;*/
    background-color: transparent;
    color:var(--text);
    cursor:pointer; line-height:1;
}
.theme-toggle .icon-sun{ display:inline; }
.theme-toggle .icon-moon{ display:none; }
.theme-toggle[data-theme="dark"]{
    /*background:#1a1c23;*/
    /*background-color: var(--panel);*/
    color:var(--text);
    border-color:var(--border);
}
.theme-toggle[data-theme="dark"] .icon-sun{ display:none; }
.theme-toggle[data-theme="dark"] .icon-moon{ display:inline; }

/* =============== STAGE/VIEW =============== */
.stage{
    position: relative;
    min-width: 0;
    min-height: 0;
    overscroll-behavior: contain;
    scrollbar-gutter: stable both-edges;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    height: calc(100vh - 52px);
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-color-stage, #111827);
}

/* 드래그 패닝 UX */
.stage.can-pan{ cursor: grab !important; touch-action: none; }
.stage.is-panning{ cursor: grabbing !important; }
.stage.is-panning, .stage.is-panning *{ user-select:none; -webkit-user-select:none; }
.stage.can-pan *:not(input):not(textarea):not(button){ cursor: inherit; }

.stage.swapping #spread{ visibility:hidden; }



/* =============== SPREAD/PAGE =============== */
.spread{
    display: flex;
}
.spread::after{
    content: "";
    position: absolute;
    /* 💡 top, bottom을 명시하여 슬롯 전체 높이에 칼같이 맞춤 */
    top: 0;
    bottom: 0;
    left: 50%;
    /* 폭을 타이트하게 60px로 고정하여 본문 침범 최소화 */
    width: 60px;
    transform: translateX(-50%);
    pointer-events: none;

    background:
        /* 1️⃣ 레이어: 중앙 틈새(Spine)의 가장 깊고 진한 핵심 세로 틈새선 */
            linear-gradient(to right,
            rgba(0, 0, 0, 0) 46%,
            rgba(0, 0, 0, calc(var(--fold-opacity) * 1.6)) 49%,
            rgba(0, 0, 0, calc(var(--fold-opacity) * 2.0)) 50%,
            rgba(0, 0, 0, calc(var(--fold-opacity) * 1.6)) 51%,
            rgba(0, 0, 0, 0) 54%
            ),
                /* 2️⃣ 레이어: 왼쪽 페이지 곡면 그림자 (가장자리 유연하게 0 투명도 마감) */
            linear-gradient(to right,
            rgba(0, 0, 0, 0) 0%,
            rgba(0, 0, 0, calc(var(--fold-opacity) * 0.2)) 60%,
            rgba(0, 0, 0, calc(var(--fold-opacity) * 0.7)) 90%,
            rgba(0, 0, 0, calc(var(--fold-opacity) * 1.1)) 98%,
            rgba(0, 0, 0, 0) 100%
            ) left / 50% 100% no-repeat,
                /* 3️⃣ 레이어: 오른쪽 페이지 곡면 그림자 */
            linear-gradient(to left,
            rgba(0, 0, 0, 0) 0%,
            rgba(0, 0, 0, calc(var(--fold-opacity) * 0.2)) 60%,
            rgba(0, 0, 0, calc(var(--fold-opacity) * 0.7)) 90%,
            rgba(0, 0, 0, calc(var(--fold-opacity) * 1.1)) 98%,
            rgba(0, 0, 0, 0) 100%
            ) right / 50% 100% no-repeat,
                /* 4️⃣ 레이어: 상하단 단면 엣지 마감 음영 (마스크 없이도 자연스럽게 끝부분이 흐려지도록 80% 투명도 지점 조율) */
            radial-gradient(100% 50% at 50% 0%, rgba(0, 0, 0, calc(var(--fold-opacity) * 0.5)) 0%, transparent 80%) top / 100% 15px no-repeat,
            radial-gradient(100% 50% at 50% 100%, rgba(0, 0, 0, calc(var(--fold-opacity) * 0.5)) 0%, transparent 80%) bottom / 100% 15px no-repeat;

    /* ❌ [원인 제거] 위아래를 강제로 흐리게 잘라내던 마스크 속성을 통째로 삭제하여 짤림 버그 해결 */
    -webkit-mask: none !important;
    mask: none !important;

    mix-blend-mode: multiply;
    opacity: 1;
    z-index: 2;
}

/* 표지(1페이지 단면)에서는 접힘(Fold) 효과 숨기기 */
.spread.is-cover::after,
.spread.is-last::after {
    opacity: 0;
    pointer-events: none;
}


.spread.is-cover .hzPrev{
    display: none;
}

.spread.is-cover .hzNext{
    display: block !important;
}


.pageSlot{
    position:relative; width:max-content; height:max-content;
    display:grid; place-items:center; overflow:hidden;
    background:var(--panel);
    /*border-radius: var(--border-radius-sm);*/
    /*border-right: 1px solid #efefef;*/
}
.pageSlot--left {

}
.pageSlot--right {
}
/* 페이지 자체도 스택 기준점으로 */
.page{ position:relative; z-index:1; }

/* 페이지 래퍼 승격 시 살짝 페이드로 전환 감추기 */
.pageSlot .page[data-prepared="1"]{ opacity:0; }
.pageSlot .page{ transition:opacity .12s ease; will-change:opacity, transform; }



/* === Single-page layout support === */
.spread.single{ grid-template-columns: 1fr !important; }
.spread.single > .pageSlot:last-child{ display:none !important; }
.spread.single .pageSlot:first-child .hotzone{ display:flex; }

.pageHost{ position:relative; display:block; overflow:hidden; }
.pageHost .canvasWrapper{ width:100%; height:auto; display:block; }
.pageHost .canvasWrapper > canvas{ width:100%; height:auto; display:block; }


.canvasWrapper canvas,
.pageHost .canvasWrapper > canvas {
    /* 💡 저해상도 모니터에서 축소된 캔버스 이미지의 대비와 가독성을 칼같이 살려주는 속성 */
    image-rendering: -webkit-optimize-contrast; /* Chrome, Edge, Safari 최적화 */
    image-rendering: crisp-edges;               /* Firefox 가독성 보정 */

    /* 픽셀 그리드 정렬 시 하드웨어 가속 레이어 승격으로 안티앨리어싱 버그 방지 */
    transform: translateZ(0);
    backface-visibility: hidden;
}


.pageHost > .textLayer{ --scale-factor: 1 !important; }

/* Dark overrides */
html.dark .pageSlot{
    background: var(--bg-color-stage);
    /*border:1px solid var(--bg-color-stage);*/
    /*box-shadow:0 6px 18px rgba(0,0,0,.35);*/
}

/* textLayer */
.pageHost > .textLayer{
    position:absolute; left:0; top:0; z-index:2;
    color:transparent; pointer-events:auto;
}
.pageHost .textLayer span{ position:absolute; white-space:pre; transform-origin:0 0; }
.pageHost .textLayer .endOfContent{ display:none !important; }

/* 기본: 복사/형광펜 모드 아닐 때 텍스트 선택/드래그 방지 */
.stage:not(.copy-mode):not(.hl-mode) .page > .textLayer,
.stage:not(.copy-mode):not(.hl-mode) .page > .textLayer *{
    user-select:none; -webkit-user-select:none; -ms-user-select:none;
    cursor:inherit;
    touch-action:none;
}

/* Overlay root */
.page > .hitOverlayRoot{
    position:absolute; left:0; top:0; z-index:3; pointer-events:none;
    transform:none; transform-origin:0 0;
}

/* Hit boxes */
.hitBox{
    position:absolute;
    pointer-events:auto;
    cursor: pointer !important;
    box-sizing:border-box;
    border-radius:2px;
    /*background: rgb(100 231 105 / 25%);*/
    background: rgb(215 39 39 / 25%);
}
.hitBox:hover{  background: rgba(88, 232, 94, 0.25); }

/* 히트박스가 준비될 때까진 보이지 않게 */
.hitOverlayRoot { visibility: hidden; }
.page.hb-ready   > .hitOverlayRoot,
.page .textLayer > .hitOverlayRoot { visibility: visible; }

/* 🔍 검색을 통해 강조된 임시 히트박스 전용 스타일 개별화 */
.hitBox[data-word*="SEARCH_HIT"], /* 스크립트 분기에 맞춤 대응 */
.hitBox.search-marker-accent {
    background: rgba(255, 230, 0, 0.45) !important; /* 선명한 형광 노란색 체킹 */
    border: 1.5px dashed #ff9900 !important;       /* 주황색 외곽 가이드라인 */
    box-shadow: 0 0 8px rgba(255, 153, 0, 0.6);

    /* ⚡ 사용자가 이동했을 때 위치를 바로 찾을 수 있도록 2초간 부드럽게 깜빡이는 애니메이션 */
    animation: searchHitGlow 1s ease-in-out infinite alternate;
}

@keyframes searchHitGlow {
    from {
        background: rgba(255, 230, 0, 0.2);
        box-shadow: 0 0 4px rgba(255, 153, 0, 0.3);
    }
    to {
        background: rgba(255, 230, 0, 0.55);
        box-shadow: 0 0 12px rgba(255, 153, 0, 0.8);
    }
}




/* 준비 중 포인터 막기 */
.page.hb-lock { pointer-events: none; }

/* Ink layer */
.page > .inkLayer{
    position:absolute; left:0; top:0; z-index:4; pointer-events:none;
}

/* Modes */
.stage.ink-on, .stage.ink-on *{ -webkit-user-select:none; user-select:none; }
.stage.ink-on .page > .textLayer{ pointer-events:none; user-select:none; }
/* 라이트 모드: 검은 펜 */
.stage.ink-on .page > .inkLayer{
    pointer-events:auto;
    cursor: url("data:image/svg+xml;utf8,\
<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'>\
<path d='M2 22l5-1 12-12a2 2 0 10-3-3L4 18 2 22z' fill='black'/>\
<path d='M14.5 5.5l4 4' stroke='white' stroke-width='2'/>\
</svg>") 2 22, crosshair;
}
/* 다크 모드: 흰 펜 */
html.dark .stage.ink-on .page > .inkLayer{
    pointer-events:auto;
    cursor: url("data:image/svg+xml;utf8,\
<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'>\
<path d='M2 22l5-1 12-12a2 2 0 10-3-3L4 18 2 22z' fill='black'/>\
<path d='M14.5 5.5l4 4' stroke='white' stroke-width='2'/>\
</svg>") 2 22, crosshair;
}


/* 추가: 지우개/사각형 지우개에서는 커서 숨김(ink.js가 inline으로도 처리하지만 백업) */
.stage.ink-on.tool-eraser .page > .inkLayer,
.stage.ink-on.tool-eraser-rect .page > .inkLayer{
    cursor: none !important;
}


/* 외부 CSS 파일 또는 <style> 태그에 추가 */
.eraser-cursor-visualizer {
    position: fixed; /* 뷰포트 기준으로 움직임 */
    pointer-events: none; /* 클릭 이벤트를 통과시켜 아래 캔버스에 전달 */
    z-index: 9999;
    border: 1px solid #ffffff; /* 흰색 테두리 */
    box-shadow: 0 0 0 1px #000000; /* 검은색 그림자 (선명도 보조) */
    background: rgba(255, 255, 255, 0.1); /* 약간 투명한 흰색 채우기 */
    display: none; /* 기본 숨김 */

    /* 하드웨어 가속 */
    will-change: transform;
}

/* Copy mode */
.stage.copy-mode .page > .textLayer,
.stage.copy-mode .page > .textLayer *{
    user-select:text; -webkit-user-select:text; -webkit-touch-callout:default;
    pointer-events:auto;
    color:rgba(0,0,0,.01);
    z-index: 1111;
}
.stage.copy-mode .hitOverlayRoot,
.stage.copy-mode .hitOverlayRoot .hitBox{ pointer-events:none; }
.stage.copy-mode .page > .inkLayer{ pointer-events:none; }

/* HL mode */
.stage.hl-mode .page > .textLayer,
.stage.hl-mode .page > .textLayer *{
    user-select:text; -webkit-user-select:text; -webkit-touch-callout:default;
    pointer-events:auto; color:rgba(0,0,0,.01);
    z-index: 1111;
}
.page > .highlightOverlayRoot{ pointer-events:none; z-index:3; }
.page > .highlightOverlayRoot .hlBox{ pointer-events:none; }



/* ===== MEMO ===== */

/* 전체 메모 레이어 글자 크기: 화면 줄어들면 같이 작아짐 */
.memoLayer{
    position:absolute;
    inset:0;
    z-index:60;
    pointer-events:none;
    font-size:clamp(11px, 0.85vw, 14px);
}

/* 메모 박스 크기: 너무 좁아지지 않도록 최소폭 보장 */
.memoNote{
    position:absolute;
    width:clamp(200px, 22%, 240px);  /* 160px 이상, 240px 이하, 평소엔 22% 정도 비율 */
    max-width:260px;
    background:#fffaf0;
    border:1px solid rgba(0,0,0,.18);
    border-radius:8px;
    box-shadow:0 8px 24px rgba(0,0,0,.2);
    pointer-events:auto;
    overflow:hidden;                 /* 안쪽 요소 튀어나오는 것 차단 */
}

/* 헤더 */
.memoNote__hd{
    display:flex;
    align-items:center;
    gap:0.5em;
    padding:0.35em 0.6em;
    background:#efe2cd;
    cursor:grab;
    user-select:none;
    font-size:0.8em;
    line-height:1.2;
    font-family:system-ui,"Noto Sans KR",sans-serif;
    color:#333;
}
.memoNote__hd:active{ cursor:grabbing; }

/* 헤더 타이틀이 박스 밖으로 안 튀게 */
.memoNote__title{
    flex:1;
    opacity:.75;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
    min-width:0;
}

.memoNote__btn{
    border:0;
    background:transparent;
    padding:0.1em 0.4em;
    cursor:pointer;
    color:#666;
}

/* 본문 */
.memoNote__body{
    padding:0.6em;
    background:transparent;
}
.memoNote__ta{
    width:100%;
    min-height:5em;
    border:0;
    outline:none;
    resize:none;
    background:transparent;
    font-size:0.9em;
    line-height:1.5;
    font-family:system-ui,"Noto Sans KR",sans-serif;
    color:#222;
}

/* 색상 선택 영역 */
.memoNote__colors{
    display:flex;
    flex-wrap:wrap; /* 폭 좁아지면 자동 줄바꿈 */
    gap:0.4em;
    padding:0.35em 0.6em;
    border-top:1px solid rgba(0,0,0,.08);
    background:rgba(0,0,0,.03);
}
.memoColor{
    width:0.9em;
    height:0.9em;
    border-radius:999px;
    border:1px solid rgba(0,0,0,.25);
    background:var(--c,#ffd);
    cursor:pointer;
}

/* 메모 본문 색 (기존 그대로) */
.memoNote[data-c="y"]{ background:#f7efe1 !important; }
.memoNote[data-c="g"]{ background:#eaf6e8 !important; }
.memoNote[data-c="b"]{ background:#e9f2fb !important; }
.memoNote[data-c="p"]{ background:#f3e9fb !important; }
.memoNote[data-c="r"]{ background:#fdeaea !important; }
.memoNote[data-c="k"]{ background:#efefef !important; }

/* 헤더는 한 톤 더 진하게 */
.memoNote[data-c="y"] .memoNote__hd { background:#ede3ce !important; }
.memoNote[data-c="g"] .memoNote__hd { background:#c6e1c4 !important; }
.memoNote[data-c="b"] .memoNote__hd { background:#c3d3e5 !important; }
.memoNote[data-c="p"] .memoNote__hd { background:#dacce6 !important; }
.memoNote[data-c="r"] .memoNote__hd { background:#e3c7c7 !important; }
.memoNote[data-c="k"] .memoNote__hd { background:#dadada !important; }

/* 접힘 상태 */
.memoNote.is-collapsed .memoNote__body,
.memoNote.is-collapsed .memoNote__colors{
    display:none;
}

/* 리사이즈 핸들 (있다면 박스 안쪽으로) */
.memoResizeHandle{
    position:absolute;
    right:4px;
    bottom:4px;
    width:12px;
    height:12px;
    border-right:2px solid rgba(0,0,0,.25);
    border-bottom:2px solid rgba(0,0,0,.25);
    opacity:.6;
    cursor:nwse-resize;
    border-radius:2px;
}

/* 중복 정의 정리용 (기존 스타일 유지) */
.memoNote.is-dragging{ opacity:.96; }




/* =============== HOTZONES (페이지 넘김) =============== */
/* 기본은 관통(클릭 막지 않음). 패닝 가능 시에만 활성 */
.hotzone{
    position:absolute;
    top:0; bottom:0;
    width:10%;
    cursor:pointer;
    display:flex;
    align-items:center;
    justify-content:center;
    z-index:50;
    background:transparent;
    border:none;
    pointer-events:auto;
}
.stage.can-pan .hotzone{ pointer-events:auto; } /* 필요 시에만 클릭 가능 */

.hotzone.left{ left:0 } .hotzone.right{ right:0 }
.hotzone .arrowIcon{
    width:clamp(20px, 8vw, 50px); height:clamp(20px, 8vw, 50px);
    pointer-events:none; opacity:.85; transition:opacity .15s ease;
}

/* 2) 텍스트 선택이 중요한 모드일 땐 핫존을 잠시 끄기 */
.stage.copy-mode .hotzone,
.stage.hl-mode   .hotzone{
    pointer-events:none;
}

/* 3) (선택) 잉크 모드에서도 페이지 넘김을 막고 싶으면 추가 */
.stage.ink-on .hotzone{
    pointer-events:none;
}


@media (hover:hover){
    .hotzone:hover .arrowIcon{ opacity:1; }
    .hotzone:hover .arrowIcon path{ stroke-opacity:1; }
}
.hotzone:focus .arrowIcon{ opacity:1; outline:none; }

/* 스프레드(양면)일 때 반대쪽 핫존 숨김 */
@media (min-width:1024px){
    /* 양면 전개(spread)일 때만 안쪽 핫존 막기 */
    .stage[data-mode="spread"]:not(.is-cover) .pageSlot:first-child  .hotzone.right {
        display:none !important;
    }
    .stage[data-mode="spread"]:not(.is-cover) .pageSlot:last-child   .hotzone.left  {
        display:none !important;
    }
}

/* 모서리 '오려내기'로 북마크 영역 비우기 */
.spread .pageSlot:last-child .hotzone.right{
    clip-path: polygon(
            0 0,
            calc(100% - var(--bm-safe)) 0,
            calc(100% - var(--bm-safe)) var(--bm-safe),
            100% var(--bm-safe),
            100% 100%,
            0 100%
    );
}
.spread .pageSlot:first-child .hotzone.left{
    clip-path: polygon(
            0 var(--bm-safe),
            var(--bm-safe) var(--bm-safe),
            var(--bm-safe) 0,
            100% 0,
            100% 100%,
            0 100%
    );
}

/* Toast */
#toast{
    position:fixed; left:50%; bottom:24px; transform:translateX(-50%);
    background:var(--panel);
    color:var(--text);
    padding:10px 14px;
    border:1px solid var(--border);
    border-radius:10px;
    display:none; z-index:9999;
    box-shadow:0 10px 24px rgba(0,0,0,.08);
    font-size: 12px;
}
/* ✅ show 클래스가 추가되었을 때 보이게 함 */
#toast.show {
    display: block;
}
html.dark #toast{
    background:#10141c;
    border:1px solid var(--border);
    box-shadow:var(--elev-shadow);
}

/* =============== SEARCH MODAL =============== */
.search-modal{ position:fixed; inset:0; background:rgba(0,0,0,.35); display:grid; place-items:center; z-index:99999; }
.search-modal.hidden{ display:none; }
.search-modal__panel{
    width:min(900px, 90vw);
    max-height:80vh;
    background:var(--panel);
    border:1px solid var(--border);
    border-radius: var(--border-radius-md);
    display:grid; grid-template-rows:auto 1fr auto;
    box-shadow:0 10px 30px rgba(0,0,0,.12);
    overflow: hidden;
}
.search-modal__head{ display:flex; gap:8px; align-items:center; padding:12px; border-bottom:1px solid var(--border); background:var(--panel-subtle-strong);
    flex-direction: column;
}
.search-modal__head input{ flex:1; background:var(--panel); border:1px solid var(--border-weak); color:var(--text); padding:8px 10px; border-radius:8px; }
.search-modal__close{ /*background:var(--panel); border:1px solid var(--border-weak); color:var(--text); border-radius:8px; padding:8px 10px;*/
    border: none;
    background-color: transparent;
    padding: 4px;
    color: var(--color-basic);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
}
.search-modal__count{
    color:var(--muted);
    font-size: var(--font-md);
}
.search-modal__body{ overflow:auto; padding:10px 12px; }
.search-result-list{ list-style:none; margin:0; padding:0; display:grid; /*gap:8px;*/ }
.search-result-list li{ background:var(--panel); /*border:1px solid var(--border);*/
    border-bottom:1px solid var(--border);
    /*border-radius:10px;*/
    /*padding:10px 12px;*/
    padding: 8px 12px;
    cursor:pointer;
}
.search-empty {
    text-align: center;
    font-size: 14px;
    line-height: 100px;
}
.search-result-list li:hover{ border-color:var(--accent); background:var(--panel-subtle); }
.search-result-list .hit{ display:flex; gap:10px;
    align-items: center;
}
.search-result-list .hit .page{
    /*min-width:56px;*/
    min-width: auto;
    /*color:var(--muted);*/
    color: #fff;
}
.search-result-list .hit .snippet{
    color:var(--text);
    font-size: var(--font-md);
}
.search-result-list mark {
    background: rgb(237 19 36 / 46%);
    border-radius: 4px;
    padding: 0 2px;
    color: var(--text);
    font-weight: 600;
}
.search-modal__pager{ /*border-top:1px solid var(--border); padding:10px 12px;*/ display:flex; gap:8px; align-items:center; justify-content:center; /*background:var(--panel-subtle);*/
    background-color: transparent;
}
.search-modal__pager button{ /*background:var(--panel); border:1px solid var(--border-weak);*/ color:var(--text); /*border-radius:8px; padding:6px 10px;*/
    background-color: transparent;
    border: none;
    padding: 0;
    height: 24px;
    cursor: pointer;
}

.search-modal__func,
.search-modal__top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}
.search-modal__top h3 {
    margin: 0;
}
.search-modal__func {
    flex-wrap: wrap;
    gap: 16px;
}
.search-modal__func input {
    width: 100%;
}
.page-indicator {
    font-size: var(--font-md);
}
.search-modal__body::-webkit-scrollbar {

}
/* ===== Chrome / Edge / Safari (WebKit/Blink) ===== */
.search-modal__body::-webkit-scrollbar{
    width: 2px;       /* 수직 스크롤바 */
    height: 2px;      /* 수평 스크롤바 */
}
.search-modal__body::-webkit-scrollbar-thumb{
    background-color: #39579b;   /* 손잡이(thumb) 색 */
    border-radius: 2px;
}
.search-modal__body::-webkit-scrollbar-track{
    background: transparent;     /* 트랙은 투명 (원하면 색 지정) */
}

/* ===== Firefox ===== */
.search-modal__body{
    scrollbar-color: #39579b transparent; /* thumb, track */
    scrollbar-width: thin;                 /* Firefox는 정확히 2px 지정 불가(최소 'thin') */
}


/* =============== TOC (왼쪽에서 슬라이드) =============== */
#tocLayer *{ box-sizing:border-box; }
.toc-layer{
    position:fixed; top:0; left:0; bottom:0; width:300px;
    background:var(--panel);
    border-right:1px solid var(--border);
    box-shadow:8px 0 20px rgba(0,0,0,.06);
    transform:translateX(-100%);
    transition:transform .22s ease;
    z-index:9999; display:flex; flex-direction:column;
}
.toc-layer.open{ transform:translateX(0); }
.toc-header{ display:flex; align-items:center; justify-content:space-between; padding:0 12px; border-bottom:1px solid var(--border); background-color: var(--panel);
    height: 62px;
}
.toc-header strong{ font-size:16px; }
.toc-close{ border:0; background:transparent; font-size:22px; line-height:1; cursor:pointer; padding:2px 6px; color:var(--text); }
.toc-tools{ padding:10px 12px; border-bottom:1px solid var(--border);
    background-color: var(--bg-panner);
}
#tocSearch{ width:100%; padding:8px 10px; border:1px solid var(--border-weak); border-radius:6px; outline:none; background:var(--panel); color:var(--text); box-sizing:border-box; }
.toc-scroll{ overflow:auto; flex:1; }
/* 2. 전역 display:none을 무시하고 .toc-scroll에만 스크롤바 스타일 부여 */
.toc-scroll::-webkit-scrollbar {
    display: block;    /* 다시 보이게 설정 */
    width: 6px;        /* 스크롤바 너비 */
}

/* 3. 스크롤바 막대(Thumb) 스타일 */
.toc-scroll::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2); /* 막대 색상 */
    border-radius: 10px;
}

/* 4. 스크롤바 배경(Track) 스타일 */
.toc-scroll::-webkit-scrollbar-track {
    background-color: rgba(0, 0, 0, 0.05); /* 배경 색상 */
}

/* 마우스 올렸을 때 막대 색상 진하게 (선택사항) */
.toc-scroll::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.4);
}
.toc-list{ list-style:none; margin:0; padding:6px 0 14px 0; }
.toc-item{ display:flex; align-items:center; justify-content:space-between; gap:8px; padding:8px 12px; cursor:pointer; transition:background .15s; }
.toc-item[data-realpage="0"] {
    opacity: .5;
    pointer-events: none;   /* 마우스 클릭 차단 */
}
.toc-item:hover{ background:var(--hover-tint); color:var(--text); }
.toc-title {
    flex: 1;
    min-width: 0;           /* 부모 너비를 넘지 않게 가둠 */
    white-space: nowrap;    /* 줄바꿈 방지 */
    overflow: hidden;       /* 넘치는 부분 숨김 */
    text-overflow: ellipsis; /* 말줄임표 표시 */
    display: block !important; /* 🔥 flex 대신 block으로 설정해야 ellipsis가 안정적으로 작동함 */
    font-size: 13px;
    line-height: 1.5;
}
.toc-page{ color:var(--muted); font-size:12px; margin-left:8px; }

/* Depth indents */
.toc-item .toc-title { display: flex; align-items: center; }
.toc-item[data-depth="0"] .toc-title{padding-left:0;  font-weight:600; }
.toc-item[data-depth="1"] .toc-title{ padding-left:8px; font-size: 16px; font-weight: 800;}
.toc-item[data-depth="2"] .toc-title{ padding-left:16px; font-size: 14px;}
.toc-item[data-depth="3"] .toc-title{ padding-left:24px; }
.toc-item[data-depth="4"] .toc-title{ padding-left:32px; }
.toc-item[data-depth="5"] .toc-title{ padding-left:48px; }
.toc-item[data-depth="6"] .toc-title{ padding-left:72px; font-size: 12px;}


/* 기존 스타일 유지하면서 아래 내용 추가/수정 */
.toc-item.has-child {
    position: relative;
}


/* 화살표 스타일 보완 */
.toc-item.has-child > .toc-title::before {
    content: '▶';
    display: inline-block;  /* block 안에서 글자처럼 흐르게 설정 */
    width: 25px;
    font-size: 12px;       /* 🔥 화살표 자체의 크기를 작게 조절 (원하는 대로 줄이세요) */
    margin-right: 4px;    /* 텍스트와의 간격 */
    text-align: center;
    transition: transform 0.2s;
    /* vertical-align: middle; 텍스트와 높이가 안 맞으면 추가 */
}
/*.toc-item:not(.has-child) > .toc-title {
    padding-left: 25px; !* 화살표 너비만큼 왼쪽 여백을 주어 텍스트 시작점을 맞춤 *!
}*/
.toc-item.has-child.open > .toc-title::before {
    transform: rotate(90deg);
}


/* =============== BOOKMARKS BUTTON =============== */
.page .bookmarkBtn{ color:#374151; opacity:.9; transition:opacity .15s ease, transform .12s ease; }
.page .bookmarkBtn:hover{ opacity:1; transform:scale(1.04); }

/* 북마크는 항상 최상위로 */
.bookmarkBtn{
    position:absolute; z-index:2100; /* 기존 100 -> 크게 상향 */
    background:transparent; border:none;
    padding:0; margin:0; width:32px; height:32px; line-height:0; cursor:pointer;
    color:#374151; user-select:none; -webkit-user-select:none; -ms-user-select:none;
    pointer-events:auto;
}
.bookmarkBtn--left{ left:0 } .bookmarkBtn--right{ right:0 }
.bookmarkBtn--top0{ top:0 } .bookmarkBtn--off6{ top:-7px }
.bookmarkBtn--off6.bookmarkBtn--left{ left:6px } .bookmarkBtn--off6.bookmarkBtn--right{ right:6px }
.bookmarkBtn svg path{ stroke:currentColor; fill:none; transition:fill .15s ease, stroke .15s ease, color .15s ease; }
.bookmarkBtn.active{ color:#e11d48; }
.bookmarkBtn.active svg path{ fill:currentColor; }

















/* =============== BOOKMARK PANEL (RIGHT) =============== */

.bm-layer,
.bm-header,
.bm-tools,
.bm-scroll,
.bm-list,
.bm-item,
.bm-link { box-sizing: border-box; }

/* 패널 컨테이너 — 통합목록과 동일 폭 */
.bm-layer{
    position:fixed;
    inset:0 0 0 auto;
    width:340px;                 /* ← anno 패널과 동일 */
    max-width:92vw;
    background:var(--panel); color:var(--text);
    transform:translateX(100%);
    transition:transform .22s ease;
    z-index:5000;
    display:grid;
    grid-template-rows:auto auto 1fr auto;  /* header / meta / list / pager */
    border-left:1px solid var(--border);
    box-shadow:-4px 0 16px rgba(0,0,0,.06);
}
.bm-layer.open{ transform:translateX(0); }
.bm-layer.loading{ cursor:progress; }
html.dark .bm-layer{ box-shadow:-4px 0 16px rgba(0,0,0,.28); }

/* 헤더 */
.bm-header{
    padding:8px 10px;
    background:var(--panel-subtle-strong);
    border-bottom:1px solid var(--border);
    overflow:hidden;             /* 내부 오버플로우 방지 */
}

/* 헤더 툴바 — 그리드로 재배치(오버플로우 없음) */
.bm-tools{
    /*display:grid;
    grid-template-columns:minmax(0,1fr) auto auto auto; !* 검색 / 정렬 / 새로고침 / 닫기 *!
    gap:6px;
    align-items:center;
    min-width:0;*/
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 입력/셀렉트 */
.bm-search,
.bm-sort{
    padding: 8px 28px 8px 8px;    /* 우측 드롭다운/아이콘 영역 확보 */
    background:var(--panel); color:var(--text);
    border:1px solid var(--border-weak);
    border-radius:6px;
    font-size:12px;
    min-width:0;
    white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
    outline: none;
}
.bm-search {
    flex: 1;
}
.bm-sort {
    border: none;
}
/* 버튼(리프레시/닫기) — 통합목록과 동일 크기 */
.bm-refresh, .bm-close{
    background:var(--panel); color:var(--text);
    border:1px solid var(--border-weak);
    border-radius:6px; cursor:pointer;
    width:28px; height:28px; padding:0;
    display:inline-grid; place-items:center;
}
.bm-refresh:hover,.bm-close:hover{ border-color:var(--accent); }

/* 리프레시 아이콘 사이즈 맞춤 */
.bm-refresh .w_undo_btn{
    width:16px; height:16px; display:block;
}
.bm-refresh .w_undo_btn path{ stroke:currentColor !important; }


#bookmarkLayer .bm-refresh,
#bookmarkLayer .bm-close{
    width: var(--panel-btn-size);
    height: var(--panel-btn-size);
    padding: 0;
    display: inline-grid;
    place-items: center;
}
#bookmarkLayer .bm-refresh svg{
    width: var(--panel-ico-size);
    height: var(--panel-ico-size);
    display: block;
}


/* 메타 */
.bm-meta{
    padding:6px 12px; font-size:12px; color:var(--muted);
    /*border-bottom:1px solid var(--border);*/
    font-weight: 800;
    overflow:hidden; white-space:nowrap; text-overflow:ellipsis;
}

/* 리스트 영역 */
.bm-scroll{ overflow:auto; min-height:0; }
.bm-list{
    list-style:none; margin:0; padding:6px;
    display:flex; flex-direction:column; gap:6px;
}

/* 아이템 카드 */
.bm-item{
    display:flex; align-items:stretch; gap:6px; background:var(--panel);
    /*border:1px solid var(--border); border-radius:10px;*/ overflow:hidden;
    border-bottom: 1px solid var(--bg-panner);
}
.bm-link{
    flex:1; text-align:left; background:transparent; border:none; padding:10px; cursor:pointer; color:var(--text);
    display:grid; grid-template-columns:auto 1fr auto; gap:8px; align-items: center;
}
.bm-link:hover{ background:var(--panel-subtle); }

.bm-page{ font-weight:700; opacity:.9; }
.bm-note{ font-size:12px; color:var(--muted); overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
.bm-upd{ font-size:11px; color:var(--muted); }

/* 삭제 버튼 */
.bm-del{
    /*width:34px; background:#fee2e2;*/
    border:none;
    cursor:pointer;
    color:#b91c1c;
    background-color: transparent;
    font-size: 24px;
}
/*.bm-del:hover{ background:#fecaca; }*/

/* 빈 상태 */
.bm-empty{
    padding:20px; text-align:center; color:var(--muted);
    border:1px dashed var(--border-weak); border-radius:10px; background:var(--panel-subtle);
}

/* 페이저 */
.bm-pager{
    display:flex; align-items:center; justify-content:center; gap:10px; padding:10px;
    border-top:1px solid var(--border); background:var(--panel-subtle);
}
.bm-prev,.bm-next{
    width:36px; height:28px; background:var(--panel); color:var(--text);
    /*border:1px solid var(--border-weak);*/
    border: none;
    border-radius: var(--border-radius-sm);
    cursor:pointer;
}
.bm-prev:hover,.bm-next:hover{ border-color:var(--accent); }
.bm-pageinfo{ font-size:12px; color:var(--muted); min-width:60px; text-align:center; }









/* =============== TOP TOOL SHELF =============== */
#toolShelf[hidden]{ display:none; }
#toolShelf{
    position:fixed; left:50%; transform:translateX(-50%); top:70px; z-index:110;
    /*background:var(--panel);*/
    background-color: var(--bg-panner);
    /*border:1px solid var(--border);*/
    border-radius: var(--border-radius-md);
    box-shadow:var(--elev-shadow);
}
#toolShelf .tool-shelf-inner{
    display:flex; align-items:center; justify-content:center;
    gap:14px; padding:10px 16px; max-width:90vw;
}
#toolShelf .tool-section{ display:contents; }
#toolShelf .tool-title{ display:none; }
#toolShelf .tool-row{ display:inline-flex; align-items:center; gap:8px; }
#toolShelf .tool-actions{ display:inline-flex; gap:8px; }
#toolShelf label{ font-size:12px; color:var(--muted); }
#toolShelf .range-wrap{ min-width:160px; }
#toolShelf .range-clip{ padding:4px 6px; border-radius:8px; }

.tool_btn{
    width: 35px;
    height:35px; padding:5px;
    background:var(--panel); border-radius:10px; color:var(--text);
    border:1px solid var(--border-weak);
}
.tool_btn_del {
    width: auto
}

/* Slider shell */
.range-wrap{
    width:90px; height:35px; padding:6px 10px;
    background:var(--panel);
    /*border:1px solid var(--border-weak);*/
    border-radius: var(--border-radius-round);
    display:flex; align-items:center; box-sizing:border-box;
}
.range-clip{
    --thumb:16px;
    width:100%; padding:0 calc(var(--thumb)/2);
    box-sizing:border-box;
}


/* Range input */
#inkSize{
    --thumb:16px; --track:4px;
    -webkit-appearance:none; appearance:none;
    width:100%; background:transparent; margin:0; padding:0;
    height:var(--thumb); display:block; border:none;
}
#inkSize::-webkit-slider-runnable-track {
    height:var(--track);
    background:var(--range-color) !important;
    border-radius:9999px;
}
#inkSize::-webkit-slider-thumb{
    -webkit-appearance:none;
    width:var(--thumb); height:var(--thumb);
    border-radius:50%; background:var(--accent); border:none;
    margin-top:calc((var(--track) - var(--thumb))/2);
}
#inkSize::-moz-range-track{
    height:var(--track);
    background:var(--range-color) !important;
    border-radius:9999px;
}
#inkSize::-moz-range-thumb{
    width:var(--thumb); height:var(--thumb);
    border-radius:50%; background:var(--accent); border:none;
}
#inkSize::-moz-range-progress{
    height:var(--track);
    background:#bfdbfe !important;
    border-radius:9999px 0 0 9999px;
}


#inkColor {
    background-color: var(--panel);
    height: 29px;
    border-radius: var(--border-radius-xs);
    border: none;
}

#inkTool{
    padding:6px 8px; background:var(--panel); color:var(--text);
    /*border:1px solid var(--border-weak);*/
    border: none;
    border-radius: var(--border-radius-sm);
}
.w_undo_btn{ width:100%; height:100%; }
.tool_btn .w_undo_btn path{ stroke: currentColor !important; }

/* Tool shelf dark 세부 트랙 컬러 */
/*html.dark #inkSize::-webkit-slider-runnable-track{ background:#2b2f39 !important; }
html.dark #inkSize::-moz-range-track{ background:#2b2f39 !important; }
html.dark #inkSize::-moz-range-progress{ background:#4da3ff !important; }*/




#highlightColor {
    background-color: var(--panel);
    height: 29px;
    border-radius: var(--border-radius-xs);
    border: none;
}

/* =============== MINIMAP =============== */
.minimap{
    position: fixed;
    right: 16px; bottom: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
    z-index: 120;
    display: none;
    overflow: hidden;
    background: #fff;
}
.minimap.show{ display: block; }
.minimap canvas{ width: 100%; height: 100%; display: block; }
.mini-viewport{
    position: absolute;
    border: 2px solid var(--accent);
    background: rgba(37,99,235,.12);
    pointer-events: auto;
    box-sizing: border-box;
    cursor: grab;
}
.mini-viewport:active{ cursor: grabbing; }

/* === Backdrop === */
.regdetail-backdrop{
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    display: none; align-items: center; justify-content: center;
    z-index: 9999;

    isolation: isolate;
    contain: layout paint;
    overflow: hidden;                 /* 팝업 뜰 때 배경 가로/세로 스크롤 방지 */
    /* backdrop-filter: blur(2px);  // 필요시 사용 */

    /* 🛠️ 1. 뒤에 깔린 어두운 배경색 반투명 레이어를 완전히 제거 */
    background: transparent !important;
    backdrop-filter: none !important;

    /* 🛠️ 2. 이 레이어 전체는 마우스 클릭/드래그를 차단하지 않고 뒤쪽 PDF 화면으로 패스시킴 */
    pointer-events: none;
}
.regdetail-backdrop[data-open="true"]{ display: flex; }

/* === Sheet === */
.regdetail-sheet{
    box-sizing: border-box;
    width: min(1040px, 94vw);         /* 가로폭 넉넉히 */
    height: min(820px, 92vh);         /* 기본 높이 업 */
    max-width: 94vw;
    max-height: 92vh;

    background: var(--panel, #fff);
    color: var(--text, #111827);
    border: 1px solid var(--border, #e5e7eb);
    /*border-radius: 16px;*/
    border-radius: var(--border-radius-sm);
    box-shadow: var(--elev-shadow, 0 24px 60px rgba(0,0,0,.25));

    display: grid;
    grid-template-rows: auto 1fr;
    overflow: hidden;
}

.regdetail-sheet table,
.regdetail-sheet table * {
    color: #000;   /* 또는 initial / inherit 등 상황에 맞게 */
}

/* [공통] 레이어 팝업 리사이즈 핸들 기본 스타일 */
.regdetail-resize-handle {
    position: absolute;
    right: 3px;
    bottom: 3px;
    width: 14px;
    height: 14px;
    cursor: se-resize;
    z-index: 50; /* 다른 요소에 묻히지 않도록 인덱스 확보 */
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center center;
    opacity: 0.7;
    transition: opacity 0.15s ease;
}

/* ☀️ 1. 라이트 모드 (기본 상태): 깔끔한 먹색/회색 빗금 */
.regdetail-resize-handle {
    background-image: linear-gradient(135deg,
    transparent 0%, transparent 45%,
    #9ca3af 45%, #9ca3af 55%,
    transparent 55%, transparent 70%,
    #9ca3af 70%, #9ca3af 80%,
    transparent 80%, transparent 90%,
    #9ca3af 90%, #9ca3af 100%
    ) !important;
}

/* 🌙 2. 다크 모드 (.dark): 배경에 묻히지 않는 강제 순백색(#ffffff) 빗금 */
.dark .regdetail-resize-handle,
[data-theme="dark"] .regdetail-resize-handle {
    background-image: linear-gradient(135deg,
    transparent 0%, transparent 45%,
    #ffffff 45%, #ffffff 55%,
    transparent 55%, transparent 70%,
    #ffffff 70%, #ffffff 80%,
    transparent 80%, transparent 90%,
    #ffffff 90%, #ffffff 100%
    ) !important;
    opacity: 0.85; /* 다크모드에서 시인성 확보를 위해 조금 더 선명하게 */
}

/* 마우스 올렸을 때 피드백 */
.regdetail-resize-handle:hover {
    opacity: 1 !important;
}
/* === Header === */
.regdetail-header{
    position: relative;
    display:flex; align-items:center; gap:12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border, #e5e7eb);
    background: var(--panel-subtle, #f8fafc);
}
.regdetail-title{
    font-weight: 700; font-size: 16px; line-height: 1.2;
    flex: 1 1 auto; min-width: 0;   /* min-width:0 → 긴 제목도 줄어들어 닫기/줌 버튼이 밀리지 않음 */
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.regdetail-close{
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 32px; height: 32px; padding: 0;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 8px;
    background: var(--panel, #fff);
    color: var(--text, #111827);
    font-size: 16px; line-height: 1; font-weight: 700;
    cursor: pointer; z-index: 1;
    border: none;
    background: transparent;
    font-size: 32px;
    font-weight: 400;
}
.regdetail-close:hover{ background: var(--panel-subtle-strong, #eef2f7); }

.regdetail-print {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 32px; height: 32px; padding: 0;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 8px;
    background: var(--panel, #fff);
    color: var(--text, #111827);
    font-size: 16px; line-height: 1; font-weight: 700;
    cursor: pointer; z-index: 1;
    border: none;
    background: transparent;
    font-size: 32px;
    font-weight: 400;
}




/* ==========================================================================
   📌 REGULATION DETAIL ZOOM CONTROLLER DESIGN (THEME VARS MATCHED)
   ========================================================================== */

/* 줌 컨트롤러 전체 감싸는 통 */
.regdetail-zoom-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px; /* 버튼 간격을 기존의 타이트한 테마 감성에 맞춰 최소화 */
    margin-right: 12px;
    margin-left: auto;
    user-select: none;
    height: 32px; /* --panel-btn-size 토큰 기준 정렬 */
    box-sizing: border-box;
}

/* 줌 영역 내 모든 버튼들 공통 스타일 세팅 */
.regdetail-zoom-control button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    height: 32px; /* 기존 헤더 버튼 및 인쇄/닫기 버튼 크기와 완벽 매칭 */
    box-sizing: border-box;

    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border-weak);
    font-size: var(--font-sm); /* 기존 font-sm(12px) 토큰 적용 */
    font-family: var(--app-font); /* 전역 앱 폰트 일치 */

    padding: 0 10px;
    cursor: pointer;
    font-weight: 600;
    line-height: 1;
    vertical-align: middle;
    transition: background-color .15s ease, border-color .15s ease;
}

/* 테두리 둥글기 맞춤 (첫 버튼의 왼쪽, 끝 버튼의 오른쪽만 깎아서 그룹화 처리) */
.regdetail-zoom-out {
    border-radius: var(--border-radius-sm) 0 0 var(--border-radius-sm) !important;
}
.regdetail-zoom-val {
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
}
.regdetail-zoom-in {
    border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0 !important;
}

/* hover 효과 기존 테마 톤으로 매칭 */
.regdetail-zoom-control button:hover {
    background: var(--hover-tint) !important;
    border-color: var(--accent) !important;
    z-index: 2; /* 테두리가 하이라이트 될 때 가려지지 않도록 조치 */
}

/* 100% 수치 표시창 디자인 고유화 */
.regdetail-zoom-val {
    min-width: 58px; /* 세 자리 숫자 및 % 기호가 들어갔을 때 깨짐 방지 균등 폭 */
    text-align: center;
    background: var(--panel) !important;
    font-weight: 700;
    cursor: pointer;
}

/* 기호 버튼 (－, ＋) 정사각형 감성으로 핏 조절 */
.regdetail-zoom-out,
.regdetail-zoom-in {
    font-size: 14px;
    width: 32px; /* 가로세로 32px 정삼각형 균형 */
    padding: 0;
}

/* ──────────────────────────────────────────────────────────
   🌓 다크 모드 자동 스위칭 오버라이드 (html.dark 대응)
   ────────────────────────────────────────────────────────── */
html.dark .regdetail-zoom-control button {
    background: #2d2d2d; /* dark theme의 --panel 대체용 고정 색상 동기화 */
    color: var(--text);
    border: 1px solid var(--border);
}

html.dark .regdetail-zoom-control button:hover {
    background: var(--hover-tint) !important;
    border-color: var(--accent) !important;
}

/* ──────────────────────────────────────────────────────────
   🔖 방문 이력 select (라이트/다크 테마 매칭)
   ────────────────────────────────────────────────────────── */
.regdetail-history {
    height: 32px;                 /* 줌/닫기 버튼과 높이 정렬 */
    box-sizing: border-box;
    max-width: 220px;
    min-width: 0;                 /* 좁은 화면에서 줄어들 수 있게 */
    flex: 0 1 auto;               /* 필요 시 축소 허용 */
    margin-left: 12px;
    margin-right: 8px;
    padding: 2px 6px;
    background: var(--panel, #fff);
    color: var(--text, #111827);
    border: 1px solid var(--border-weak, #e5e7eb);
    border-radius: var(--border-radius-sm, 6px);
    font-family: var(--app-font);
    font-size: var(--font-sm, 12px);
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease;
}
.regdetail-history:hover,
.regdetail-history:focus {
    outline: none;
    border-color: var(--accent);
}
.regdetail-history option {
    background: var(--panel, #fff);
    color: var(--text, #111827);
}

/* 다크 모드 오버라이드 (html.dark / .dark / [data-theme="dark"]) */
html.dark .regdetail-history,
.dark .regdetail-history,
[data-theme="dark"] .regdetail-history {
    background: #2d2d2d;
    color: var(--text, #e5e7eb);
    border: 1px solid var(--border);
}
html.dark .regdetail-history:hover,
html.dark .regdetail-history:focus,
.dark .regdetail-history:hover,
.dark .regdetail-history:focus,
[data-theme="dark"] .regdetail-history:hover,
[data-theme="dark"] .regdetail-history:focus {
    border-color: var(--accent) !important;
}
html.dark .regdetail-history option,
.dark .regdetail-history option,
[data-theme="dark"] .regdetail-history option {
    background: #2d2d2d;
    color: var(--text, #e5e7eb);
}


/* 1. 글자 크기는 자바스크립트가 bodyEl에 직접 부여한 % 배율을 하위 요소들이 그대로 상속받게 강제함 */
.regdetail-body * {
    font-size: inherit !important;
}

/* 2. line-height 역시 자바스크립트가 동적으로 계산해 준 CSS 변수를 강제로 주입함 */
.regdetail-body,
.regdetail-body * {
    line-height: var(--dynamic-lh, 1.6) !important;
}

/* === Body / iframe === */
.regdetail-body{
    overflow-y: auto;
    overflow-x: hidden;               /* 가로 스크롤 제거 */
    padding: 16px;
    min-height: 0;                    /* grid 자식 높이 전파 */
    -webkit-overflow-scrolling: touch;
}
.regdetail-frame{
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}




/* 상태 메시지 */
.regdetail-body .regdetail-loading{ padding: 24px; text-align: center; font-size: 14px; color: var(--muted, #6b7280); }
.regdetail-body .regdetail-error{ padding: 24px; color: #c0392b; font-weight: 600; }

/* 문서 스크롤 잠금 토글 */
html.no-scroll, body.no-scroll { overflow: hidden; }

/* 모바일 */
@media (max-width: 600px){
    .regdetail-sheet{
        width: 96vw;
        height: min(72vh, 640px);
        max-height: 80vh;
        border-radius: 12px;
    }
    /* 모바일 헤더: 2줄 레이아웃
       - 1줄: 제목(축소·말줄임) + 줌 + 닫기  → 버튼 항상 노출
       - 2줄: 이력 select 전체 폭 (제목 아래로 내림) */
    .regdetail-header{ padding: 10px 12px; gap: 6px; flex-wrap: wrap; row-gap: 8px; }
    .regdetail-body{ padding: 12px; }
    .regdetail-title{ font-size: 14px; flex: 1 1 auto; min-width: 0; }
    .regdetail-zoom-control{ margin-left: auto; margin-right: 0; gap: 1px; flex: 0 0 auto; }
    .regdetail-zoom-val{ min-width: 44px; }
    .regdetail-zoom-out, .regdetail-zoom-in{ width: 28px; }
    .regdetail-zoom-control button{ padding: 0 6px; }
    .regdetail-close{ flex: 0 0 auto; }
    .regdetail-history{
        order: 1;              /* 제목/줌/닫기(order 0) 다음 → 둘째 줄로 */
        flex: 1 1 100%;
        width: 100%;
        max-width: 100%;
        margin: 0;
    }
}



/* =============== ANNO PANEL (RIGHT) =============== */
.am-layer,
.am-header,
.am-tools,
.am-scroll,
.am-list,
.am-item,
.am-link { box-sizing: border-box; }

/* 패널 컨테이너 */
.am-layer{
    position:fixed;
    inset:0 0 0 auto;
    width:340px;                 /* 살짝 넓혀서 잘림 방지 (원하면 320~360로 조정) */
    max-width:92vw;
    background:var(--panel); color:var(--text);
    transform:translateX(100%);
    transition:transform .22s ease;
    z-index:5000;
    display:grid;
    grid-template-rows:auto auto 1fr auto;  /* header / meta / list / pager */
    border-left:1px solid var(--border);
    box-shadow:-4px 0 16px rgba(0,0,0,.06);
}
.am-layer.open{ transform:translateX(0); }
.am-layer.loading{ cursor:progress; }

/* 헤더: 타이틀 제거 가정(컨트롤만 배치) */
.am-header{
    padding:8px 10px;
    background:var(--panel-subtle-strong);
    border-bottom:1px solid var(--border);
    overflow:hidden;             /* 내부가 튀어나오지 않게 */
}

/* 헤더 툴바 레이아웃
   [ 타입 select ][ 정렬 select ][ 새로고침 ][ 닫기 ] */
.am-tools{
    /*display:grid;
    grid-template-columns:minmax(0,1fr) minmax(0,1fr) auto auto;
    gap:6px;
    align-items:center;
    min-width:0; */                /* 그리드 수축 허용 */
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 입력/셀렉트 공통 */
.am-types, .am-sort {
    padding: 7px 28px 7px 8px;    /* 우측 화살표 영역 확보 */
    background:var(--panel); color:var(--text);
    border:1px solid var(--border-weak); border-radius:6px; font-size:12px;
    min-width:0;
    white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
    outline: none;
}
.am-types {
    flex: 1;
}
.am-sort {
    background: var(--bg-panner);
    border: none;
}
/* 검색 인풋은 사용 안함 → 혹시 DOM에 있어도 숨김 */
.am-search{ display:none !important; }

/* 버튼 */
.am-refresh, .am-close{
    background:var(--panel); color:var(--text);
    border:1px solid var(--border-weak);
    border-radius:6px; cursor:pointer;
    width:28px; height:28px; padding:0;
    display:inline-grid; place-items:center;
}
.am-refresh .w_undo_btn path { stroke: currentColor !important; }
.am-refresh:hover, .am-close:hover{ border-color:var(--accent); }


#annoLayer .am-refresh,
#annoLayer .am-close{
    width: var(--panel-btn-size);
    height: var(--panel-btn-size);
    padding: 0;
    display: inline-grid;
    place-items: center;
}

#annoLayer .am-refresh svg{
    width: var(--panel-ico-size);
    height: var(--panel-ico-size);
    display: block;
}

#annoLayer .am-refresh .w_undo_btn path{
    stroke: currentColor !important; /* 북마크와 동일한 스트로크 색상 */
}

/* 선택: 라운드/호버 효과도 북마크와 동일하게 */
#annoLayer .am-refresh:hover,
#annoLayer .am-close:hover{
    border-color: var(--accent);
}


/* 상단 메타 */
.am-meta{
    padding:6px 12px; font-size:12px; color:var(--muted);
    /*border-bottom:1px solid var(--border);*/
    font-weight: 800;
    overflow:hidden; white-space:nowrap; text-overflow:ellipsis;
}

/* 리스트 스크롤 영역 */
.am-scroll{ overflow:auto; min-height:0; }

/* 리스트 */
.am-list{
    list-style:none; margin:0; padding:6px;
    display:flex; flex-direction:column; gap:6px;
}

/* 아이템 카드 */
.am-item{
    display:flex; align-items:stretch; gap:6px; background:var(--panel);
    /*border:1px solid var(--border); border-radius:10px;*/
    overflow:hidden;
    border-bottom: 1px solid var(--bg-panner);
}

/* 아이템 버튼 */
.am-link{
    flex:1; text-align:left; background:transparent; border:none; padding:10px; cursor:pointer; color:var(--text);
    display:grid; grid-template-columns:auto 1fr auto; gap:8px; align-items: center;
}
.am-link:hover{ background:var(--panel-subtle); }

/* 필드 톤 */
.am-page{ font-weight:700; opacity:.9; }
.am-type{/* font-size:12px; color:var(--muted); */
    font-size: var(--font-md);
    color: var(--muted);
    font-weight: 700;
}
.am-type.t-memo{ color:#8b5cf6; }
.am-type.t-highlight{ color:#f59e0b; }
.am-type.t-ink{ color:#10b981; }
.am-date{ font-size:11px; color:var(--muted); }

/* 빈 상태 */
.am-empty{
    padding:20px; text-align:center; color:var(--muted);
    border:1px dashed var(--border-weak); border-radius:10px; background:var(--panel-subtle);
}

/* 하단 페이저 */
.am-pager{
    display:flex; align-items:center; justify-content:center; gap:10px; padding:10px;
    border-top:1px solid var(--border); background:var(--panel-subtle);
}
.am-prev,.am-next{
    width:36px; height:28px; background:var(--panel); color:var(--text);
    /*border:1px solid var(--border-weak); border-radius:6px; cursor:pointer;*/
    border: none;
    border-radius: var(--border-radius-sm);
    cursor:pointer;
}
.am-prev:hover,.am-next:hover{ border-color:var(--accent); }
.am-pageinfo{ font-size:12px; color:var(--muted); min-width:60px; text-align:center; }

/* 다크 모드 대비(선택) — 시스템 토큰만 쓰면 생략 가능 */
html.dark .am-layer{ box-shadow:-4px 0 16px rgba(0,0,0,.28); }



#resumePopup.resume-backdrop{
    position: fixed; inset: 0; z-index: 10000;
    display: none; align-items: center; justify-content: center;
    background: rgba(0,0,0,.35);
    pointer-events: auto;
}
#resumePopup.resume-backdrop.show{ display:flex; }

#resumePopup .resume-sheet{
    background: var(--rp-panel);
    color: var(--rp-text);
    min-width: 280px; max-width: 92vw;
    padding: 20px 20px 16px;
    border-radius: 12px;
    box-shadow: var(--rp-shadow);
}
#resumePopup .resume-title{
    font-size: 16px; font-weight: 700; margin-bottom: 8px;
}
#resumePopup .resume-body{
    font-size: 14px; margin-bottom: 16px; line-height: 1.55;
}
#resumePopup .resume-actions{
    display: flex; gap: 8px; justify-content: flex-end;
}
#resumePopup .resume-btn{
    padding: 8px 12px; border-radius: 8px; cursor: pointer;
    border: 1px solid var(--rp-border);
    background: var(--rp-panel);
    color: var(--rp-text);
}

/* (선택) hover 살짝 톤업 */
#resumePopup .resume-btn:hover{
    background: var(--panel-subtle-strong);
}

/* 예 버튼(강조)은 그대로 유지 */
#resumePopup .resume-btn.resume-yes{
    background: var(--rp-accent);
    border-color: var(--rp-accent);
    color: #fff;
}
#resumePopup .resume-btn:focus{
    outline: 2px solid color-mix(in oklab, var(--rp-accent) 40%, white);
    outline-offset: 1px;
}

.layer-header {
    display: flex;
    flex-direction: column;
    padding: 0;
    background-color: var(--panel);
}
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 61px;
    padding: 0 12px;
    border-bottom: 1px solid var(--border);
}
.sidebar-header h4 {
    margin: 0;
    font-size: var(--font-2xl);
}
.sidebar-header .layer-close {
    width: auto;
    height: auto;
    background: transparent;
    border: none;
}
.layer-tools {
    background-color: var(--bg-panner);
    padding: 8px 12px;
}
.layer-func {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
}
.layer-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
    padding: 0;
    margin: 60px 0 0;
    color: var(--icon-color);
    border: none;
    border-radius: 0;
    background: transparent;
}
.empty-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    color:var(--text);
}
.empty-text * {
    margin: 0;
    text-align: center;
}
.empty-text h1 {
    font-size: var(--font-xl);
    color: var(--text);
}
.empty-text p {
    color: var(--text);
    word-break: keep-all;
    font-size: var(--font-sm);
}

.badge {
    background-color: #39579b;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

html.dark .bgcolorGray {
    background-color: var(--panel-subtle, #f8fafc) !important;
    border: none;
    color: var(--text, #111827) !important;
}

.btn_func_more {
    display: none;
    cursor: pointer;
    color: var(--icon-color);
}
.btn_func_more_close {
    display: none;
    cursor: pointer;
    color: var(--icon-color);
}
.txt-a1{
    color:#000;
}
@media screen and (max-width: 1024px) {
    html header {
        backdrop-filter: none;
    }
    header .controls-left {
        /*order: 1;
        flex: none;
        width: 35%;*/
        flex: auto;
    }
    header .controls-center {
        /*order: 3;
        flex: none;
        width: 100%;
        margin: 16px 0;*/
        flex: auto;
        position: fixed;
        right: 0;
        bottom: 12px;
        left: 50%;
        transform: translateX(-50%);
        justify-content: center;
        padding: 8px 12px;
        background: var(--bg-panner);
        width: max-content;
        border-radius: var(--border-radius-md);
    }
    header .controls-right {
        /*order: 2;
        flex: none;
        width: 65%;*/
        flex: auto;
    }
    .modeBtnWrap .modeBtn svg {
        width: 20px;
        height: 20px;
    }
    .modeBtnWrap .modeBtn span {
        /*display: none;*/
    }
    #jumpInput {
        width: auto !important;
        border: none;
    }
    #toolShelf {
        top: inherit;
        bottom: 80px;
    }
    #toolShelf .tool-shelf-inner {
        width: max-content;
    }

    .spread::after {
        display: none;
    }
}

@media screen and (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 12px;
        position: fixed;
        top: inherit;
        bottom: 0;
    }
    header svg {
        width: 18px;
        height: 18px;
    }
    /*#printToggle svg,
    #themeToggle svg {
        width: 24px;
        height: 24px;
    }*/
    header .controls-left,
    header .controls-right {
        width: 100%;
        justify-content: start;
    }
    header .controls-right {
        /*margin-bottom: 14px;*/
    }
    header .controls-center {
        /*justify-content: start;
        left: 0;
        transform: none;
        width: 100vw;
        box-sizing: border-box;
        bottom: 0;
        border-radius: 0;*/
        display: none;
        position: absolute;
        bottom: 10px;
    }
    .controls-center[data-open="true"]{
        display: flex;
        bottom: 0;
        left: 0;
        transform: none;
        width: 100%;
        box-sizing: border-box;
        padding: 8px 8px 8px 14px;
        justify-content: start;
    }
    #jumpInput {
        /*width: calc(100% - 185px) !important;*/
        /*flex: 1;*/
        /*width: 60px !important;*/
        width: calc(100% - 277px) !important;
        max-width: 135px;
    }


    .modeBtnWrap .modeBtn span {
        /*display: none;*/
        font-size: var(--font-xs);
    }

    /*#printToggle {
        position: fixed;
        bottom: 16px;
        right: 48px;
    }
    #themeToggle {
        position: fixed;
        bottom: 16px;
        right: 12px;
    }*/
    #printToggle {
        margin-left: auto;
    }
    #toolShelf {
        bottom: 52px;
        border-radius: 0;
        transform: none;
        left: 0;
        right: 0;
    }

    #toolShelf .tool-shelf-inner {
        width: 100vw;
        flex-wrap: wrap;
    }
    /*header .controls-center svg {
        width: 24px;
        height: 24px;
    }*/
    .btn_func_more_close {
        display: flex;
        align-items: center;
        justify-content: center;
        margin-left: auto;

    }
    .modeBtnWrap {
        gap: 4px;
        padding: 4px 8px;
        height: 36px;
        box-sizing: border-box;
        flex: 1;
    }
    header .modeBtnWrap button.modeBtn {
        flex: 1;
        justify-content: center;
    }
    .modeBtnWrap .modeBtn svg {
        width: 14px;
        height: 14px;
    }

    .input_common,
    .input_area {
        height: 36px;
    }
    .func_keyword_search {
        flex: 1;
        /*position: absolute;
        top: 10px;
        right: 14px;
        width: calc(100% - 275px);*/
    }
    #headerSearchInput {
        width: 100% !important;
    }

    .func_zoom {
        /*position: fixed;
        right: 14px;
        bottom: 85px;*/
        position: absolute;
        top: 5px;
        right: 14px;
    }

    .toc-layer,
    .bm-layer,
    .am-layer {
        width: 100vw;
        max-width: 100vw;
    }

    .search-modal__panel {
        width: 100vw;
        max-height: 100dvh;
        border: none;
        border-radius: 0;
    }

    .minimap {
        right: inherit;
        left: 10px;
        top: 10px;
        bottom: inherit;
    }

    .btn_func_more {
        display: flex;
        align-items: center;
        justify-content: center;
    }


    #stage {
        /* 높이 계산:
         * 100lvh (안전한 뷰포트)
         * - [STAGE TOP] (stage 상단이 화면 맨 위에서 떨어져 있는 공간)
         * - [HEADER HEIGHT] (하단 고정 바의 높이)
         */
        height: calc(100svh - var(--stage-top-offset) - 95px);
        /* 105px는 JS에서 사용하던 기본 헤더 높이입니다.
           실제 CSS에서는 하단 헤더/툴바의 고정된 높이로 대체해야 합니다. */
    }

    #inkTool {
        height: 29px;
    }

    #inkColor {
        width: 50px;
    }

    #highlightColor {
        width: 50px;
    }

}


/* 3D 공간을 정의하는 외부 컨테이너 */
.perspective-wrapper {
    width: 80px;
    height: 70px;
    position: relative;
    margin: 0 auto 16px auto;
    perspective: 300px; /* 원근감 깊이 세팅 */
    transform-style: preserve-3d;
}

/* ✨ 바닥에 깔리는 리얼한 책 그림자 효과 */
.book-floor-shadow {
    position: absolute;
    bottom: 5px;
    left: 5%;
    width: 90%;
    height: 20px;
    background: rgba(0, 0, 0, 0.4);
    filter: blur(6px);
    border-radius: 50%;
    transform: rotateX(80deg); /* 바닥에 납작하게 눕힘 */
    z-index: 1;
}

/* ✨ 약간 누워있는 형태의 책 본체 */
.lying-book {
    width: 76px;
    height: 48px;
    position: absolute;
    top: 10px;
    left: 2px;
    z-index: 2;
    transform-style: preserve-3d;

    /* X축으로 42도 눕히고, Y축을 살짝 틀어 비스듬한 입체감 연출 */
    transform: rotateX(42deg) rotateY(-10deg) rotateZ(5deg);

    border: 2.5px solid #ffffff;
    border-radius: 4px;
    background: linear-gradient(90deg, #cbd5e1 0%, #ffffff 15%, #ffffff 85%, #cbd5e1 100%);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* 책 중앙의 깊이감 있는 접힘선 */
.book-spine-center {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(15, 23, 42, 0.2);
    transform: translateX(-50%);
    z-index: 10;
}

/* 누워있는 궤적을 따라 뒤집히는 책 페이지 */
.lying-page {
    position: absolute;
    top: 0;
    right: 0;
    width: 50%;
    height: 100%;
    background: #f8fafc;
    border-radius: 0 6px 3px 0;
    transform-origin: left center;
    transform-style: preserve-3d;

    /* 종이가 부드럽게 넘어가도록 타임라인 가속도 최적화 */
    animation: lyingBookFlip 1.8s infinite cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow:
            inset -4px 0 10px rgba(0, 0, 0, 0.05),
            -1px 1px 3px rgba(0, 0, 0, 0.1);
}

/* 페이지 겹침 딜레이 */
.lying-page:nth-child(2) { animation-delay: 0.3s; }
.lying-page:nth-child(3) { animation-delay: 0.6s; }
.lying-page:nth-child(4) { animation-delay: 0.9s; }

/* 🔄 누운 각도를 유지하며 페이지가 플립되는 3D 키프레임 */
@keyframes lyingBookFlip {
    0% {
        transform: rotateY(0deg);
        opacity: 1;
        background: #ffffff;
        box-shadow: inset -4px 0 10px rgba(0, 0, 0, 0.05);
    }
    45% {
        background: #f1f5f9;
        /* 넘어가면서 세워질 때 음영 깊이 표현 */
        box-shadow: inset -8px 0 12px rgba(0, 0, 0, 0.15);
    }
    85% {
        opacity: 1;
    }
    100% {
        transform: rotateY(-180deg);
        opacity: 0;
        background: #cbd5e1;
    }
}