/* 보호형 뷰어 화면 스타일. 흑백 계열, 밝은 배경 */
:root { --ink: #1c1c1c; --sub: #5d5d5d; --line: #cfcfcf; --bg: #f1f1f1; --panel: #ffffff; --bar-h: 48px; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.5;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
.noscript { padding: 40px; text-align: center; }

/* 뷰어 뼈대 */
.btn:focus-visible, .goto input:focus-visible, .toc button:focus-visible, .hotspots button:focus-visible, .stage:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.viewer { height: 100%; display: grid; grid-template-rows: var(--bar-h) 1fr 28px; }
.bar { display: flex; align-items: center; gap: 10px; padding: 0 10px; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; }
.bar .title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pager, .tools { display: flex; align-items: center; gap: 6px; flex: none; }
.btn { height: 32px; min-width: 36px; padding: 0 10px; border: 1px solid #8c8c8c; background: #fff; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #ededed; }
.btn:disabled { opacity: .4; cursor: default; }
.goto { display: flex; align-items: center; gap: 6px; margin: 0; font-variant-numeric: tabular-nums; }
.goto input { width: 44px; height: 32px; text-align: center; border: 1px solid #8c8c8c; background: #fff; -webkit-user-select: text; user-select: text; }
.goto span { color: var(--sub); white-space: nowrap; }

/* 확대했을 때 왼쪽·위쪽이 잘리지 않도록 가운데 맞춤은 margin:auto 로 한다. */
.stage { position: relative; overflow: auto; background: var(--bg); padding: 16px; display: flex; -webkit-overflow-scrolling: touch; }
.sheet { position: relative; background: #fff; box-shadow: 0 1px 6px rgba(0, 0, 0, .28); line-height: 0; flex: none; margin: auto; }
.sheet canvas { display: block; width: 100%; height: 100%; pointer-events: none; }
/* 그림 위를 덮는 층. 오른쪽 단추·끌기가 그림에 닿지 않게 하고, 목차 쪽에서는 바로가기 단추가 놓인다. */
.hotspots { position: absolute; inset: 0; }
.hotspots button { position: absolute; border: 0; background: transparent; padding: 0; cursor: pointer; }
.hotspots button:hover { background: rgba(0, 0, 0, .06); }
.status { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); margin: 0; padding: 8px 14px; background: #fff; border: 1px solid var(--line); color: var(--sub); line-height: 1.5; }
.status:empty { display: none; }

.foot { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 0 12px; background: var(--panel); border-top: 1px solid var(--line); color: var(--sub); font-size: 12px; white-space: nowrap; overflow: hidden; }

/* 목차 서랍 */
.toc { position: fixed; z-index: 5; top: var(--bar-h); left: 0; bottom: 28px; width: min(360px, 88vw); overflow: auto; background: var(--panel); border-right: 1px solid var(--line); box-shadow: 2px 0 8px rgba(0, 0, 0, .12); padding: 14px 10px 20px; }
.toc h2 { margin: 0 8px 8px; font-size: 15px; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc button { display: flex; gap: 10px; width: 100%; text-align: left; border: 0; border-bottom: 1px solid #e6e6e6; background: transparent; padding: 9px 8px; cursor: pointer; line-height: 1.4; }
.toc button:hover, .toc button.on { background: #ededed; }
.toc button .no { flex: none; width: 56px; color: var(--sub); font-variant-numeric: tabular-nums; white-space: nowrap; }
.toc button .t { flex: 1; }
.toc button.new .t, .toc button.overview .t { font-weight: 700; }
.toc button.new .t::after, .toc button.overview .t::after { margin-left: 8px; padding: 1px 6px; border: 1px solid var(--ink); font-size: 11px; font-weight: 600; white-space: nowrap; }
.toc button.new .t::after { content: "새 내용"; }
.toc button.overview .t::after { content: "개요"; background: var(--ink); color: #fff; }
.toc button .st { flex: none; align-self: flex-start; margin-top: 2px; padding: 0 5px; border: 1px solid var(--line); color: var(--sub); font-size: 11px; white-space: nowrap; }

/* 가림막 */
.veil { position: fixed; z-index: 20; inset: 0; background: #e9e9e9; display: grid; place-items: center; text-align: center; color: var(--ink); font-weight: 600; padding: 24px; }
.veil p { margin: 0; }
body.veiled .sheet { visibility: hidden; }

.print-block { display: none; }
@media print {
  body > *:not(.print-block) { display: none !important; }
  .print-block { display: block; padding: 40px; font-size: 16pt; }
}

@media (max-width: 720px) {
  .bar { gap: 6px; padding: 0 6px; }
  .bar .title { display: none; }
  .pager { flex: 1; justify-content: center; }
  #zoomOut, #zoomIn { display: none; }
  .stage { padding: 8px; }
  .foot span:last-child { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .toc button { transition: background-color .12s; }
}
