@font-face {
  font-family: 'KRFont';
  src: url('vendor/NanumGothic-Regular.ttf') format('truetype');
  font-weight: 400;
}
@font-face {
  font-family: 'KRFont';
  src: url('vendor/NanumGothic-Bold.ttf') format('truetype');
  font-weight: 700;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }
body {
  font-family: 'KRFont', 'Malgun Gothic', sans-serif;
  background: #52585f;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ---------- 툴바 ---------- */
#toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 10px;
  background: #ffffff;
  border-bottom: 1px solid #d8dce1;
  flex-wrap: wrap;
  z-index: 30;
}
.tb-group { display: flex; align-items: center; gap: 2px; }
.tb-sep { width: 1px; height: 34px; background: #e0e3e8; margin: 0 6px; }
.tb-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 58px; padding: 4px 6px;
  border: 1px solid transparent; border-radius: 8px;
  background: none; cursor: pointer;
  font-family: inherit;
}
.tb-btn .ico { height: 20px; display: flex; align-items: center; color: #3a3f46; }
.ico svg, .sec-ico svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sec-ico { display: inline-flex; vertical-align: -3px; color: #4a5058; }
.sec-ico svg { width: 15px; height: 15px; }
.tb-btn .lbl { font-size: 11px; color: #333; white-space: nowrap; }
.tb-btn:hover:not(:disabled) { background: #eef2f7; }
.tb-btn.active { background: #dbe9ff; border-color: #a9c8f5; }
.tb-btn:disabled { opacity: .35; cursor: default; }
.tb-mini {
  padding: 4px 10px; border: 1px solid #c9ced5; border-radius: 6px;
  background: #fff; cursor: pointer; font-family: inherit; font-size: 12px;
}
.tb-mini:hover { background: #eef2f7; }
.tb-mini.danger { color: #c02626; border-color: #e2b4b4; }
.tb-mini.danger:hover { background: #fdeeee; }
.tb-mini.primary { background: #2b6cd4; color: #fff; border-color: #2b6cd4; }
.tb-mini.primary:hover { background: #2159b3; }
.zoomer { gap: 6px; }
#zoomPct { font-size: 12px; min-width: 42px; text-align: center; color: #333; }
.page-info { font-size: 12px; color: #555; margin-left: 8px; white-space: nowrap; }
/* ---------- 텍스트 서식 바 (선택된 개체 위에 표시) ---------- */
.fmtbar {
  position: absolute;
  bottom: 100%; margin-bottom: 6px; left: 0;
  display: none;
  flex-direction: column;
  gap: 3px;
  padding: 4px 6px;
  background: #fff;
  border: 1px solid #c9ced5;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  white-space: nowrap;
  z-index: 10;
  cursor: default;
  touch-action: auto;
  width: max-content;
}
.fmtbar.below { bottom: auto; top: 100%; margin-bottom: 0; margin-top: 6px; }
.annot.selected .fmtbar { display: flex; }
.fb-row { display: flex; align-items: center; gap: 3px; }
.fmtbar input, .fmtbar button { font-family: inherit; font-size: 12px; }
.fmtbar button {
  min-width: 24px; height: 24px; padding: 0 5px;
  border: 1px solid #c9ced5; border-radius: 5px;
  background: #fff; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  color: #333;
}
.fmtbar button svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fmtbar button:hover { background: #eef2f7; }
.fmtbar button.on { background: #dbe9ff; border-color: #2b6cd4; color: #2b6cd4; }
.fmtbar .fb-b { font-weight: 900; }
.fmtbar .fb-i { font-style: italic; }
.fb-num { min-width: 22px; text-align: center; font-size: 12px; color: #333; }
.fb-sizedn, .fb-sizeup { font-size: 11px; }
.fb-sw {
  width: 18px !important; height: 18px !important;
  min-width: 18px !important; max-width: 18px; flex: 0 0 18px;
  padding: 0 !important; margin: 0 1px;
  border-radius: 50% !important; border: 1px solid rgba(0,0,0,.18) !important;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.4);
  transition: transform .1s;
}
.fb-sw:hover { transform: scale(1.2); }
.fb-sw.on { box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px #2b6cd4; transform: scale(1.05); }
.fb-custom {
  width: 18px; height: 18px; flex: 0 0 18px; padding: 0; margin: 0 1px;
  border: 1px solid rgba(0,0,0,.18); border-radius: 50%;
  cursor: pointer; background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
  overflow: hidden; transition: transform .1s;
}
.fb-custom:hover { transform: scale(1.2); }
.fb-custom::-webkit-color-swatch-wrapper { padding: 0; opacity: 0; }
.fb-custom::-webkit-color-swatch { opacity: 0; }
.fb-shape-btn svg { width: 15px; height: 15px; }
.fmtbar .fb-del { color: #c02626; border-color: #e2b4b4; margin-left: 4px; }
.fmtbar .fb-del:hover { background: #fdeeee; }
.svg-btn svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- 탭바 ---------- */
#tabBar {
  display: flex; align-items: flex-end; gap: 2px;
  padding: 4px 8px 0; background: #e8eaee; border-bottom: 1px solid #d0d4da;
  overflow-x: auto; scrollbar-width: thin;
}
#tabBar.hidden { display: none; }
.tab {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px 5px 12px; max-width: 200px;
  background: #d7dae0; border: 1px solid #c5c9d0; border-bottom: none;
  border-radius: 8px 8px 0 0; cursor: pointer; font-size: 12px; color: #555;
  white-space: nowrap; user-select: none;
}
.tab.active { background: #fff; color: #222; font-weight: bold; }
.tab .t-name { overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.tab .t-close {
  border: none; background: none; cursor: pointer; color: #8a8f97;
  font-size: 12px; padding: 1px 4px; border-radius: 4px; line-height: 1;
}
.tab .t-close:hover { background: #cfd3da; color: #333; }
.tab-plus {
  border: none; background: none; cursor: pointer; font-size: 15px; color: #666;
  padding: 4px 9px; border-radius: 6px 6px 0 0;
}
.tab-plus:hover { background: #d7dae0; }

/* ---------- 메인 ---------- */
#main { flex: 1; display: flex; min-height: 0; position: relative; }

/* 하단 중앙 페이지 표시/이동 */
#pageJump {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 5px;
  background: rgba(28, 32, 38, .78); color: #eee;
  border-radius: 18px; padding: 5px 14px; z-index: 20;
  font-size: 13px; backdrop-filter: blur(2px);
}
#pageJump.hidden { display: none; }
#pjInput {
  width: 44px; text-align: center; font-family: inherit; font-size: 13px;
  background: rgba(255,255,255,.12); color: #fff;
  border: 1px solid rgba(255,255,255,.25); border-radius: 8px; padding: 2px 4px;
}
#pjInput:focus { outline: none; border-color: #7aa7e8; background: rgba(255,255,255,.2); }
#pjInput::-webkit-outer-spin-button, #pjInput::-webkit-inner-spin-button { -webkit-appearance: none; }
#viewer {
  flex: 1; overflow: auto; padding: 24px 0 60vh;
  outline: none;
  scroll-behavior: auto;
  position: relative;
}
.doc-view.hidden { display: none; }
#emptyState {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
}
#emptyState.hidden { display: none; }
#emptyState p { color: #b9bec6; font-size: 13px; }
#emptyState .big-btn { flex-direction: row; gap: 8px; font-size: 17px; padding: 14px 30px; }
#emptyState .big-btn svg { width: 20px; height: 20px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- 페이지 ---------- */
.page {
  position: relative;
  margin: 0 auto 66px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,.35);
}
.page canvas { position: absolute; left: 0; top: 0; display: block; }
.page .ext-area {
  position: absolute;
  background: #fdfdf4;
}
.page .ext-area::before {
  content: '필기 영역';
  position: absolute; top: 4px; left: 8px;
  font-size: 10px; color: #b9b98a; pointer-events: none;
}
.page .ext-r { border-left: 1px dashed #d8d8b0; }
.page .ext-b { border-top: 1px dashed #d8d8b0; }
.page .overlay { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
.overlay .annot { pointer-events: auto; }

/* 원본 텍스트 선택용 레이어 (pdf.js text layer) */
.textLayer {
  position: absolute; left: 0; top: 0; overflow: hidden;
  line-height: 1; forced-color-adjust: none; transform-origin: 0 0;
  text-size-adjust: none;
}
.textLayer span, .textLayer br {
  color: transparent; position: absolute; white-space: pre;
  cursor: text; transform-origin: 0 0;
}
.textLayer ::selection { background: rgba(43, 108, 212, .35); }
.page .pnum {
  position: absolute; bottom: -16px; right: 2px;
  font-size: 11px; color: #cfd3d8; pointer-events: none;
}

/* 도구별 커서 */
.tool-text .overlay { cursor: text; }
.tool-edit .overlay, .tool-erase .overlay { cursor: crosshair; touch-action: none; }

/* 모바일: 개체를 드래그할 때 화면 스크롤 방지 */
.annot, .annot .rs, .annot .rs-w { touch-action: none; }

/* ---------- 주석(개체) ---------- */
.annot { position: absolute; }
.annot.selected { outline: 1.5px solid #2b6cd4; outline-offset: 1px; }
.annot .rs {
  position: absolute; right: -6px; bottom: -6px; width: 12px; height: 12px;
  background: #2b6cd4; border: 2px solid #fff; border-radius: 50%;
  cursor: nwse-resize; display: none; box-shadow: 0 0 3px rgba(0,0,0,.4);
}
.annot .rs-w {
  position: absolute; right: -6px; top: 50%; margin-top: -6px; width: 12px; height: 12px;
  background: #2b6cd4; border: 2px solid #fff; border-radius: 50%;
  cursor: ew-resize; display: none; box-shadow: 0 0 3px rgba(0,0,0,.4);
}
.annot.selected .rs, .annot.selected .rs-w { display: block; }

.annot.text { min-height: 14px; cursor: move; outline: 1px dashed rgba(130, 142, 160, .55); }
.annot.text.bubble { background: #fff; border-radius: 8px; border: 1.5px solid #333; }
.annot.text .txt {
  font-family: 'KRFont', sans-serif;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
  padding: 2px;
  min-height: 1em;
  outline: none;
  cursor: inherit;
}
.annot.text.editing { cursor: text; outline: 1.5px dashed #2b6cd4; }
.annot.text.editing .txt { cursor: text; }
.annot.text:not(.editing):hover { outline: 1.5px dashed #9db8dd; }
.annot.text .txt:empty::before { content: '입력…'; color: #b5b9bf; }

.annot.image { cursor: move; }
.annot.image img { width: 100%; height: 100%; display: block; user-select: none; -webkit-user-drag: none; }

.annot.whiteout { background: #fff; cursor: move; }
.annot.whiteout:hover { outline: 1px dashed #d5b0b0; }

/* 말풍선/지시선 SVG */
svg.shape { position: absolute; overflow: visible; pointer-events: none; }
svg.shape .anch, svg.shape .anch-hit { pointer-events: all; cursor: move; touch-action: none; }
svg.shape .line-hit { pointer-events: stroke; cursor: pointer; touch-action: none; }

/* 페이지 바깥 가장자리 버튼 (필기영역/페이지 추가) */
.edge-btn {
  border: 1px dashed #9aa0a8; background: rgba(255, 255, 255, .1);
  color: #cfd3d8; border-radius: 6px; font-size: 11px; cursor: pointer;
  font-family: inherit; opacity: .6; transition: all .15s; padding: 3px 8px;
  white-space: nowrap;
}
.edge-btn:hover { opacity: 1; background: #fff; color: #333; border-color: #666; border-style: solid; }
.note-add-r {
  position: absolute; z-index: 6;
  left: 100%; margin-left: 8px; top: 45%;
  writing-mode: vertical-rl; padding: 8px 3px;
}
.page-below {
  position: absolute; z-index: 6; top: 100%; left: 50%;
  transform: translateX(-50%); margin-top: 7px;
  display: flex; flex-direction: column; gap: 4px; align-items: center;
}

/* 필기영역 크기 조절 핸들 (양쪽 화살표 표시) */
.ext-rs { position: absolute; z-index: 7; touch-action: none; display: none; }
.ext-rs-r { top: 0; right: -6px; width: 12px; height: 100%; cursor: ew-resize; }
.ext-rs-b { left: 0; bottom: -6px; height: 12px; width: 100%; cursor: ns-resize; }
.ext-rs::after {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 13px; color: #9aa0a8; background: rgba(255,255,255,.85);
  border: 1px solid #d5dae1; border-radius: 8px; padding: 1px 3px; line-height: 1.2;
  opacity: .65; pointer-events: none;
}
.ext-rs-r::after { content: '↔'; }
.ext-rs-b::after { content: '↕'; }
.ext-rs:hover, .ext-rs.on { background: rgba(43, 108, 212, .18); }
.ext-rs:hover::after, .ext-rs.on::after { opacity: 1; color: #2b6cd4; border-color: #a9c8f5; }

/* 필기영역 제거 버튼 */
.ext-del {
  position: absolute; z-index: 7;
  width: 18px; height: 18px; line-height: 1;
  border: 1px solid #d5c9c9; border-radius: 50%;
  background: rgba(255,255,255,.9); color: #b08585; font-size: 10px;
  cursor: pointer; display: none; padding: 0;
}
.ext-del:hover { background: #fdeeee; color: #c02626; border-color: #e2b4b4; }
.ext-del-r { top: 4px; right: 4px; }
.ext-del-b { bottom: 4px; left: 4px; }

.rubber {
  position: absolute; border: 1.5px dashed #2b6cd4; background: rgba(43,108,212,.08);
  pointer-events: none;
}

/* ---------- 북마크 패널 ---------- */
#bmPanel, #notesPanel {
  width: 320px; background: #f7f8fa; border-left: 1px solid #d8dce1;
  display: flex; flex-direction: column;
}
#bmPanel.hidden, #notesPanel.hidden { display: none; }

/* 필기 모아보기 카드 */
.note-card {
  display: flex; gap: 10px; margin: 8px 10px; padding: 8px;
  background: #fff; border: 1px solid #e2e5ea; border-radius: 10px; cursor: pointer;
}
.note-card:hover { border-color: #a9c8f5; background: #f4f8fe; }
.nc-thumb {
  width: 58px; flex: none; border: 1px solid #e0e3e8; background: #fff;
  border-radius: 4px; overflow: hidden; align-self: flex-start;
}
.nc-thumb canvas { display: block; width: 100%; }
.nc-body { flex: 1; min-width: 0; }
.nc-page {
  font-size: 11px; color: #2b6cd4; background: #e4edfb;
  display: inline-block; border-radius: 10px; padding: 1px 8px; margin-bottom: 4px;
}
.nc-text {
  font-size: 12px; color: #333; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
  max-height: 108px; overflow: hidden;
}
.bm-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; font-weight: bold; font-size: 14px;
  border-bottom: 1px solid #e2e5ea; background: #fff;
}
.bm-body { flex: 1; overflow: auto; display: flex; flex-direction: column; }
.bm-sec-title {
  font-size: 13px; font-weight: bold; padding: 12px 14px 0;
  display: flex; flex-direction: column; gap: 2px;
}
.bm-sec-title small { font-weight: normal; color: #8b929b; font-size: 11px; }
#tocList, #markList { padding: 4px 8px; }
.bm-add {
  margin: 8px 12px 4px; padding: 8px; border: 1px dashed #a9c8f5; border-radius: 8px;
  background: #eef4fd; color: #2b6cd4; cursor: pointer; font-family: inherit; font-size: 13px;
}
.bm-add:hover { background: #dfeafc; }
.bm-item {
  display: flex; align-items: center; gap: 3px;
  padding: 3px 4px; border-radius: 6px; margin-bottom: 2px;
}
.bm-item:hover { background: #eceff4; }
.bm-item.lv1 { margin-left: 22px; }
.bm-item input.bm-title {
  flex: 1; min-width: 0; border: 1px solid transparent; background: none;
  font-family: inherit; font-size: 13px; padding: 3px 4px; border-radius: 4px;
}
.bm-item input.bm-title:hover { border-color: #d5dae1; background: #fff; }
.bm-item input.bm-title:focus { border-color: #2b6cd4; background: #fff; outline: none; }
.bm-page {
  font-size: 11px; color: #2b6cd4; background: #e4edfb; border: none; border-radius: 10px;
  padding: 2px 8px; cursor: pointer; font-family: inherit; white-space: nowrap;
}
.bm-page:hover { background: #d0e0f8; }
.bm-item .tb-icon {
  border: none; background: none; cursor: pointer; font-size: 12px; color: #7a828c;
  padding: 2px 3px; border-radius: 4px;
}
.bm-item .tb-icon:hover { background: #dde2e9; color: #333; }
.bm-hint { font-size: 11px; color: #8b929b; padding: 8px 14px 12px; line-height: 1.5; }
.bm-empty { text-align: center; color: #9aa0a8; font-size: 12px; padding: 24px 0; }

/* ---------- 시작 화면 ---------- */
#welcome {
  position: fixed; inset: 0; background: #52585f;
  display: flex; align-items: center; justify-content: center; z-index: 40;
}
#welcome.hidden { display: none; }
#dropZone {
  background: #fff; border-radius: 20px; padding: 48px 64px; text-align: center;
  border: 3px dashed transparent;
}
#dropZone.over { border-color: #2b6cd4; background: #eef4fd; }
.w-icon { font-size: 52px; }
#dropZone h1 { font-size: 24px; margin: 8px 0 16px; }
#dropZone p { color: #666; margin: 6px 0; font-size: 14px; }
.w-sub { font-size: 12px !important; color: #9aa0a8 !important; margin-top: 18px !important; }
.big-btn {
  display: inline-flex; flex-direction: column; gap: 2px; align-items: center;
  margin: 10px 6px 0; padding: 12px 26px;
  font-size: 16px; font-family: inherit;
  background: #2b6cd4; color: #fff; border: none; border-radius: 10px; cursor: pointer;
}
.big-btn:hover { background: #2159b3; }
.big-btn small { font-size: 11px; opacity: .8; }

/* ---------- 모달 ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(20,24,30,.5);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal.hidden { display: none; }
.modal-box {
  background: #fff; border-radius: 14px; padding: 16px 20px 20px;
  max-width: 680px; width: calc(100% - 40px); max-height: 90vh; overflow: auto;
}
.modal-box.small { max-width: 420px; text-align: center; }
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  font-weight: bold; font-size: 15px; margin-bottom: 12px;
}
#sigCanvas {
  width: 100%; border: 1px solid #d5dae1; border-radius: 10px;
  background: #fcfcfa; cursor: crosshair; touch-action: none;
}
.sig-tools { display: flex; align-items: center; gap: 14px; margin-top: 10px; font-size: 13px; flex-wrap: wrap; }
.sig-sec-title { font-size: 13px; font-weight: bold; margin: 12px 0 6px; }
.sig-hint { font-weight: normal; color: #8b929b; font-size: 11px; }
#sigList { display: flex; gap: 10px; flex-wrap: wrap; min-height: 40px; }
.sig-item { position: relative; border: 1px solid #d5dae1; border-radius: 8px; padding: 4px; cursor: pointer; background: #fff; }
.sig-item:hover { border-color: #2b6cd4; background: #eef4fd; }
.sig-item img { height: 44px; display: block; }
.sig-item .sig-del {
  position: absolute; top: -7px; right: -7px; width: 18px; height: 18px;
  border-radius: 50%; border: none; background: #c02626; color: #fff;
  font-size: 10px; line-height: 1; cursor: pointer; display: none;
}
.sig-item:hover .sig-del { display: block; }
.sig-empty { color: #9aa0a8; font-size: 12px; align-self: center; }
.note-desc { font-size: 13px; color: #555; line-height: 1.6; margin-bottom: 14px; }
.note-btns { display: flex; justify-content: center; gap: 8px; margin-bottom: 16px; }

/* 지시선 서식 팝업 */
#linePop .modal-box { text-align: left; }
.lp-row { display: flex; align-items: center; gap: 10px; margin: 14px 0; font-size: 13px; }
.lp-label { width: 52px; color: #555; flex: none; }
.lp-val { min-width: 34px; color: #333; }
#lpW { flex: 1; }
.lp-btns { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.lp-btns button {
  min-width: 30px; height: 28px; padding: 0 8px;
  border: 1px solid #c9ced5; border-radius: 6px; background: #fff;
  cursor: pointer; font-family: inherit; font-size: 12px;
  display: inline-flex; align-items: center; justify-content: center;
}
.lp-btns button:hover { background: #eef2f7; }
.lp-btns button.on { background: #dbe9ff; border-color: #2b6cd4; color: #2b6cd4; }
.lp-btns .lp-sw {
  width: 20px; height: 20px; min-width: 20px; padding: 0;
  border-radius: 50%; border: 1px solid rgba(0,0,0,.18);
}
.lp-btns .lp-sw.on { box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px #2b6cd4; }
.lp-btns input[type="color"] {
  width: 20px; height: 20px; padding: 0; border: 1px solid rgba(0,0,0,.18); border-radius: 50%;
  cursor: pointer; background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); overflow: hidden;
}
.lp-btns input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; opacity: 0; }
.lp-btns input[type="color"]::-webkit-color-swatch { opacity: 0; }

/* ---------- 로딩 ---------- */
#busy {
  position: fixed; inset: 0; background: rgba(255,255,255,.6);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  z-index: 60; font-size: 14px; color: #333;
}
#busy.hidden { display: none; }
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 4px solid #c9d8f0; border-top-color: #2b6cd4;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 문서 내 검색 (V1) ---------- */
#searchBar {
  position: absolute; top: 56px; right: 28px; z-index: 40;
  display: flex; align-items: center; gap: 6px;
  background: #fff; border: 1px solid #c9ced5; border-radius: 8px;
  padding: 6px 8px; box-shadow: 0 4px 16px rgba(0,0,0,.18);
}
#searchBar.hidden { display: none; }
#searchInput {
  width: 200px; border: none; outline: none; font-family: inherit; font-size: 13px;
}
#searchCount { font-size: 12px; color: #6b7280; min-width: 44px; text-align: right; white-space: nowrap; }
.searchLayer {
  position: absolute; left: 0; top: 0; pointer-events: none; z-index: 3;
}
.search-hl {
  position: absolute; background: rgba(255, 213, 79, .45); border-radius: 2px;
}
.search-hl.cur { background: rgba(255, 152, 0, .55); outline: 2px solid rgba(230, 120, 0, .9); }

/* ---------- 두 페이지 보기 (V3) ---------- */
.doc-view.two-up {
  display: grid; grid-template-columns: repeat(2, max-content);
  justify-content: center; column-gap: 22px; align-items: start;
}
.doc-view.two-up .page { margin: 0 0 66px; }
.tb-mini.on { background: #dbe9ff; border-color: #a9c8f5; }

/* ---------- 상단 2단 툴바 + 모드 탭 (U1) ---------- */
#toolbar { flex-direction: column; gap: 0; padding: 4px 10px 0; }
.tb-row { display: flex; align-items: center; justify-content: center; gap: 4px; flex-wrap: wrap; width: 100%; }
#toolRow { border-top: 1px solid #eef0f3; margin-top: 4px; padding: 3px 0; min-height: 50px; }
#toolRow .tools { display: flex; align-items: center; gap: 2px; }
#toolRow .tools.hidden { display: none; }
.tools-hint { font-size: 11.5px; color: #8b929c; margin-left: 10px; }
.mode-tab {
  padding: 7px 16px; border: 1px solid transparent; border-radius: 999px;
  background: none; cursor: pointer; font-family: inherit; font-size: 13px; color: #333;
}
.mode-tab:hover:not(:disabled) { background: #eef2f7; }
.mode-tab.active { background: #dbe9ff; border-color: #a9c8f5; font-weight: 700; }
.mode-tab:disabled { opacity: .35; cursor: default; }

/* ---------- 왼쪽 사이드바 (U2) ---------- */
#sidebar {
  width: 208px; flex: none; display: flex; flex-direction: column;
  background: #f4f5f7; border-right: 1px solid #d8dce1; min-height: 0;
}
#sidebar.hidden { display: none; }
#sbTabs { display: flex; border-bottom: 1px solid #d8dce1; background: #fff; }
.sb-tab {
  flex: 1; padding: 8px 2px; border: none; background: none; cursor: pointer;
  font-family: inherit; font-size: 12px; color: #666; border-bottom: 2px solid transparent;
}
.sb-tab:hover { background: #eef2f7; }
.sb-tab.active { color: #2b6cd4; border-bottom-color: #2b6cd4; font-weight: 700; }
.sb-pane { flex: 1; overflow-y: auto; min-height: 0; }
.sb-pane.hidden { display: none; }

/* 썸네일 (V2) */
#thumbList { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 14px 8px 24px; }
.thumb {
  position: relative; cursor: pointer; border-radius: 4px;
  border: 2px solid transparent; padding: 2px; max-width: 100%;
}
.thumb.cur { border-color: #2b6cd4; }
.thumb:hover { background: #e6eaf0; }
.thumb.drag-over { outline: 2px dashed #2b6cd4; outline-offset: 2px; }
.thumb canvas {
  display: block; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3);
  max-width: 100%;
}
.thumb .th-num {
  text-align: center; font-size: 11px; color: #666; margin-top: 3px;
}
.thumb .th-ops {
  position: absolute; top: 4px; right: 4px; display: none; gap: 2px;
}
.thumb:hover .th-ops { display: flex; }
.thumb .th-ops button {
  border: 1px solid #c9ced5; background: rgba(255,255,255,.95); border-radius: 4px;
  cursor: pointer; font-size: 11px; padding: 2px 5px; font-family: inherit;
}
.thumb .th-ops button:hover { background: #eef2f7; }

/* ---------- 하단 상태바 (U4) ---------- */
#statusBar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 3px 14px; background: #fff; border-top: 1px solid #d8dce1; z-index: 30;
}
#statusBar.hidden { display: none; }
#statusBar .st-left, #statusBar .st-right { display: flex; align-items: center; gap: 6px; }
#statusBar .st-left span { font-size: 12px; color: #666; }
#statusBar #pjInput {
  width: 48px; padding: 3px 4px; border: 1px solid #c9ced5; border-radius: 6px;
  font-family: inherit; font-size: 12px; text-align: center;
}
#statusBar #zoomPct { font-size: 12px; color: #333; min-width: 40px; text-align: center; }

/* ---------- 시작 화면: 최근 문서 (U3) ---------- */
#emptyState .privacy-line { color: #9aa0a8; font-size: 12px; margin-top: -6px; }
#recentWrap { margin-top: 26px; width: min(560px, 86%); }
.recent-title { font-size: 13px; color: #c3c8cf; margin-bottom: 10px; }
#recentList { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.recent-card {
  position: relative; background: #fff; border: 1px solid #d8dce1; border-radius: 8px;
  padding: 12px 12px 10px; cursor: pointer; text-align: left;
}
.recent-card:hover { background: #eef2f7; }
.recent-card .rc-name {
  font-size: 12.5px; color: #222; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; padding-right: 14px;
}
.recent-card .rc-date { font-size: 11px; color: #9aa0a8; margin-top: 4px; }
.recent-card .rc-del {
  position: absolute; top: 6px; right: 6px; display: none;
  border: none; background: none; cursor: pointer; color: #9aa0a8; font-size: 11px; padding: 2px;
}
.recent-card:hover .rc-del { display: block; }
.recent-card .rc-del:hover { color: #c02626; }

/* ---------- 주석 도구 (A1–A3) ---------- */
#annotStyle { display: flex; align-items: center; gap: 8px; margin: 0 4px; }
#annotColors { display: flex; gap: 4px; }
#annotColors .clr {
  width: 17px; height: 17px; border-radius: 50%; border: 1.5px solid rgba(0,0,0,.15);
  cursor: pointer; padding: 0;
}
#annotColors .clr.on { outline: 2px solid #2b6cd4; outline-offset: 1.5px; }
#annotLwWrap { display: flex; align-items: center; gap: 4px; font-size: 11px; color: #666; visibility: hidden; }
#annotLwWrap input { width: 70px; }

/* 마크업: 상자는 클릭 통과, 칠해진 부분만 클릭 */
.annot.markup { pointer-events: none; background: none; }
.annot.markup .mk { position: absolute; pointer-events: auto; cursor: pointer; }
.annot.markup .mk-hl { opacity: .42; mix-blend-mode: multiply; border-radius: 2px; }
.annot.markup.selected { outline: 1.5px dashed #2b6cd4; }
.annot.markup .fmtbar { pointer-events: auto; }

/* 펜/도형 */
.annot.ink, .annot.shape { background: none; pointer-events: none; }
.annot.ink svg, .annot.shape svg {
  position: absolute; left: 0; top: 0; width: 100%; height: 100%;
  pointer-events: none; display: block;
}
.annot.ink svg .hit, .annot.shape svg .hit { pointer-events: auto; cursor: pointer; }
.annot.shape svg rect, .annot.shape svg ellipse { pointer-events: auto; cursor: pointer; }
.annot.ink.selected, .annot.shape.selected { outline: 1.5px dashed #2b6cd4; }
.annot.ink .fmtbar, .annot.shape .fmtbar, .annot.ink .rs, .annot.shape .rs { pointer-events: auto; }
.ink-live { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }

/* 그리기/마크업 도구 커서 */
.tool-draw .overlay { cursor: crosshair; touch-action: none; }
.tool-draw .page, .tool-draw .textLayer { touch-action: none; }
.tool-markup .textLayer { cursor: text; }

/* ---------- 주석 목록 (A6) ---------- */
#annotList { padding: 10px 10px 20px; }
.al-page { font-size: 11px; color: #8b929c; margin: 12px 2px 4px; font-weight: 700; }
.al-page:first-child { margin-top: 2px; }
.al-row {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px;
  background: #fff; border: 1px solid #e2e5ea; border-radius: 6px; margin-bottom: 4px;
  cursor: pointer; font-size: 12px;
}
.al-row:hover { background: #eef2f7; }
.al-chip { width: 10px; height: 10px; border-radius: 3px; flex: none; border: 1px solid rgba(0,0,0,.12); }
.al-label { color: #333; flex: none; }
.al-snippet { color: #8b929c; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; }

/* 탭 드롭 대상 (P3) */
.tab.drag-over { outline: 2px dashed #2b6cd4; outline-offset: -2px; }

/* OCR 투명 텍스트 (S3) */
.textLayer .ocr-word {
  position: absolute; color: transparent; white-space: pre;
  line-height: 1; cursor: text; transform-origin: 0 0;
}

/* ---------- 사이드바 폭 + 리사이즈 ---------- */
#sidebar { width: var(--sbw, 420px); min-width: 240px; max-width: 640px; }
#sbResize { width: 5px; flex: none; cursor: col-resize; background: transparent; }
#sbResize:hover, #sbResize.on { background: #b9c4d4; }
#sidebar.hidden + #sbResize { display: none; }
#thumbList { flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: flex-start; }

/* ---------- 우측 주석·필기 패널 ---------- */
#annotBar {
  width: 320px; flex: none; display: flex; flex-direction: column;
  background: #f4f5f7; border-left: 1px solid #d8dce1; min-height: 0;
}
#annotBar.hidden { display: none; }
#annotBar .bm-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; background: #fff; border-bottom: 1px solid #d8dce1; font-size: 13px; font-weight: 700;
}
#annotBar .bm-body { flex: 1; overflow-y: auto; min-height: 0; }
#annotFilters { display: flex; gap: 4px; padding: 8px 10px 0; }
.af-btn {
  padding: 3px 10px; border: 1px solid #c9ced5; border-radius: 999px; background: #fff;
  cursor: pointer; font-family: inherit; font-size: 11.5px; color: #555;
}
.af-btn.active { background: #dbe9ff; border-color: #a9c8f5; color: #1c5fd6; font-weight: 700; }

/* 주석 행 개편: 아이콘 + 5줄 스니펫 + 확장 */
.al-row { align-items: flex-start; }
.al-ico { flex: none; width: 16px; height: 16px; color: #4a5058; margin-top: 1px; }
.al-ico svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.al-snippet {
  flex: 1; white-space: pre-wrap; overflow: hidden; font-size: 12px; color: #333;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 5;
  word-break: break-word;
}
.al-row.open .al-snippet { display: block; -webkit-line-clamp: unset; }
.al-snippet[contenteditable="true"] {
  display: block; -webkit-line-clamp: unset; outline: 1.5px solid #2b6cd4;
  border-radius: 4px; background: #fff; padding: 2px 4px; cursor: text;
}
.al-pg { flex: none; font-size: 11px; color: #8b929c; margin-top: 1px; }
.al-expand {
  flex: none; border: none; background: none; cursor: pointer; color: #8b929c;
  font-size: 10px; padding: 2px; margin-top: 1px;
}
.al-expand:hover { color: #2b6cd4; }

/* ---------- 현재 단원 표시 + 페이지 오버레이 ---------- */
#sectionChip {
  position: absolute; top: 10px; z-index: 25; transform: translateX(-50%);
  background: rgba(30, 33, 38, .82); color: #fff; font-size: 12px;
  padding: 4px 14px; border-radius: 999px; pointer-events: none;
  max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#sectionChip.hidden { display: none; }
#pageJump {
  position: absolute; bottom: 16px; z-index: 25; transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px;
  background: rgba(30, 33, 38, .82); border: none; border-radius: 999px;
  padding: 4px 12px; color: #fff; font-size: 12px;
}
#pageJump.hidden { display: none; }
#pageJump input {
  width: 40px; border: none; border-radius: 5px; background: rgba(255,255,255,.15);
  color: #fff; font-family: inherit; font-size: 12px; text-align: center; padding: 2px;
  outline: none;
}
#pageJump input:focus { background: #fff; color: #222; }

/* ---------- 목차 행 개편 ---------- */
.bm-item { gap: 4px; }
.bm-item.dragging { opacity: .45; }
.bm-item.drag-over { outline: 2px dashed #2b6cd4; outline-offset: -2px; }
.bm-titletext {
  flex: 1; font-size: 12.5px; color: #222; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 3px 2px;
}
.bm-titletext:hover { color: #2b6cd4; }
.bm-edit {
  flex: none; border: none; background: none; cursor: pointer; color: #8b929c; padding: 2px;
}
.bm-edit:hover { color: #2b6cd4; }
.bm-edit svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tm-text { flex: 1; padding: 5px 8px; border: 1px solid #c9ced5; border-radius: 6px; font-family: inherit; font-size: 13px; }
.tm-page { width: 70px; padding: 5px 8px; border: 1px solid #c9ced5; border-radius: 6px; font-family: inherit; font-size: 13px; }
.tm-actions { justify-content: flex-end; gap: 6px; }
