/* ═══════════════════════════════════════════════
   viewer.css — HWP Studio Shell
   ═══════════════════════════════════════════════ */

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

:root {
  --color-primary: #6182d6;
  --color-primary-dark: #335095;
  --color-primary-light: #4a90d9;
  --color-success: #4a7a43;
  --color-danger: #b64444;
  --color-surface: #ffffff;
  --color-surface-raised: #fafafa;
  --color-bg: #f0f0f0;
  --color-bg-light: #f6f6f6;
  --color-editor-bg: #d7d7d7;
  --color-border: #c0c0c0;
  --color-border-light: #d0d0d0;
  --color-border-dark: #b4b4b4;
  --color-text: #333333;
  --color-text-secondary: #555555;
  --color-text-muted: #6b6b6b;
  --color-text-disabled: #aaaaaa;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
  --shadow-dropdown: 2px 2px 8px rgba(0, 0, 0, 0.15);
  --shadow-light: 2px 2px 6px rgba(0, 0, 0, 0.12);
  --shadow-paper: 0 2px 8px rgba(0, 0, 0, 0.15);
  --radius: 4px;
  --radius-sm: 2px;
  --radius-md: 3px;
  --menu-height: 28px;
  --toolbar-height: 56px;
  --style-height: 28px;
  --status-height: 22px;
  --sidebar-width: 156px;
  --ruler-size: 20px;
}

html, body {
  height: 100%;
  font-family: 'Malgun Gothic', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  font-size: 12px;
  color: var(--color-text);
  background: var(--color-bg);
  overflow: hidden;
}

body {
  min-height: 100vh;
}

#studio-root {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--color-bg);
}

/* ── 메뉴바 ──────────────────────────────────── */
#menu-bar {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 8px;
  height: var(--menu-height);
  background: #f5f5f5;
  border-bottom: 1px solid var(--color-border-light);
  flex-shrink: 0;
}

.menu-item {
  position: relative;
  user-select: none;
}

.menu-title {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 14px;
  border: 1px solid transparent;
  cursor: default;
  color: var(--color-text);
}

.menu-item:hover > .menu-title {
  background: #e2e6f1;
  border-color: #96a6cd;
  color: var(--color-primary-dark);
}

.menu-dropdown {
  display: none;
  position: absolute;
  top: calc(100% - 1px);
  left: 0;
  min-width: 180px;
  padding: 4px 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-dropdown);
  z-index: 60;
}

.menu-item:hover > .menu-dropdown {
  display: block;
}

.md-item {
  display: flex;
  width: 100%;
  padding: 6px 14px;
  border: 0;
  background: transparent;
  font: inherit;
  color: var(--color-text);
  text-align: left;
  cursor: default;
}

.md-item:hover {
  background: #e9eefb;
  color: var(--color-primary-dark);
}

.md-sep {
  height: 1px;
  margin: 3px 8px;
  background: #e1e1e1;
}

/* ── 아이콘 툴바 ─────────────────────────────── */
#icon-toolbar {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 2px 8px;
  height: var(--toolbar-height);
  background: linear-gradient(to bottom, #fafafa, #efefef);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  overflow: hidden;
}

.tb-group {
  display: flex;
  align-items: stretch;
}

.tb-sep {
  width: 1px;
  margin: 4px 5px;
  background: #c0c0c0;
  flex-shrink: 0;
}

.tb-btn {
  min-width: 44px;
  padding: 2px 5px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font: inherit;
}

.tb-btn:hover:not(:disabled) {
  background: #dfe4ec;
  border-color: #b0b8c8;
}

.tb-btn:disabled {
  color: var(--color-text-disabled);
  cursor: not-allowed;
}

.tb-btn-accent {
  color: var(--color-primary-dark);
}

.tb-glyph {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: linear-gradient(180deg, #ebf1ff, #cbd8fa);
  color: var(--color-primary-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.tb-btn:disabled .tb-glyph {
  background: linear-gradient(180deg, #f1f1f1, #dddddd);
  color: #999999;
}

.tb-sprite {
  display: block;
  width: 18px;
  height: 18px;
  background-image: url('../images/icon_small_ko.svg');
  background-repeat: no-repeat;
  background-size: auto;
  flex-shrink: 0;
}

.icon-save { background-position: calc(-40px * 1) calc(-40px * 0); }
.icon-print { background-position: calc(-40px * 4) calc(-40px * 0); }
.icon-find { background-position: calc(-40px * 15) calc(-40px * 1); }
.icon-zoom-out { background-position: 0 -960px; }
.icon-zoom-in { background-position: -40px -960px; }
.icon-zoom-fit-width { background-position: -80px -960px; }
.icon-zoom-fit { background-position: -120px -960px; }

.tb-label {
  font-size: 10px;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
  color: var(--color-text-secondary);
}

.tb-spacer {
  flex: 1;
}

.tb-docinfo {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 10px;
}

.app-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 22px;
  padding: 0 8px;
  border-radius: 11px;
  background: #dce4f5;
  color: var(--color-primary-dark);
  font-weight: 700;
  letter-spacing: 0.05em;
}

.app-title {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.file-name {
  min-width: 0;
  max-width: 320px;
  padding: 3px 10px;
  border: 1px solid #d3d8e5;
  border-radius: 11px;
  background: #f8fafc;
  color: var(--color-text-muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.export-group {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.save-format-select {
  height: 30px;
  padding: 0 8px;
  border: 1px solid #b8b8b8;
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--color-text);
  font: inherit;
}

/* ── 서식 바 ─────────────────────────────────── */
#style-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 1px 8px;
  height: var(--style-height);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  white-space: nowrap;
}

.sb-sep {
  width: 1px;
  height: 20px;
  background: #c0c0c0;
  margin: 0 4px;
  flex-shrink: 0;
}

.sb-combo {
  height: 22px;
  padding: 0 2px;
  border: 1px solid #b0b0b0;
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--color-text);
  font: inherit;
}

.sb-combo:disabled,
.sb-size:disabled {
  color: var(--color-text-muted);
}

.sb-font-lang {
  width: 44px;
}

.sb-font {
  width: 110px;
}

.sb-size-group {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
}

.sb-size {
  width: 36px;
  height: 22px;
  border: 1px solid #b0b0b0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  border-right: 0;
  background: #ffffff;
  color: var(--color-text);
  text-align: center;
  font: inherit;
}

.sb-size-unit {
  height: 22px;
  line-height: 22px;
  padding: 0 3px;
  border: 1px solid #b0b0b0;
  border-right: 0;
  background: #e8e8e8;
  color: var(--color-text-secondary);
}

.sb-size-arrows {
  display: inline-flex;
  flex-direction: column;
}

.sb-arrow {
  width: 14px;
  height: 11px;
  border: 1px solid #b0b0b0;
  background: #e8e8e8;
  color: var(--color-text-secondary);
  font-size: 6px;
  line-height: 1;
  padding: 0;
}

.sb-btn {
  width: 24px;
  height: 24px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sb-ga {
  font-size: 16px;
  line-height: 1;
  font-family: 'Malgun Gothic', sans-serif;
}

.sb-bold { font-weight: 700; }
.sb-italic { font-style: italic; }
.sb-underline { text-decoration: underline; }

.sb-align {
  width: 14px;
  height: 14px;
  display: inline-block;
  background:
    linear-gradient(#666, #666) left 0 top 1px / 14px 1px no-repeat,
    linear-gradient(#666, #666) left 0 top 5px / 14px 1px no-repeat,
    linear-gradient(#666, #666) left 0 top 9px / 14px 1px no-repeat,
    linear-gradient(#666, #666) left 0 top 13px / 14px 1px no-repeat;
}

.sb-al-center {
  background:
    linear-gradient(#666, #666) center top 1px / 10px 1px no-repeat,
    linear-gradient(#666, #666) center top 5px / 14px 1px no-repeat,
    linear-gradient(#666, #666) center top 9px / 10px 1px no-repeat,
    linear-gradient(#666, #666) center top 13px / 14px 1px no-repeat;
}

.sb-al-right {
  background:
    linear-gradient(#666, #666) right top 1px / 10px 1px no-repeat,
    linear-gradient(#666, #666) right top 5px / 14px 1px no-repeat,
    linear-gradient(#666, #666) right top 9px / 10px 1px no-repeat,
    linear-gradient(#666, #666) right top 13px / 14px 1px no-repeat;
}

.sb-al-justify {
  background:
    linear-gradient(#666, #666) left top 1px / 14px 1px no-repeat,
    linear-gradient(#666, #666) left top 5px / 14px 1px no-repeat,
    linear-gradient(#666, #666) left top 9px / 14px 1px no-repeat,
    linear-gradient(#666, #666) left top 13px / 14px 1px no-repeat;
}

/* ── WASM 바 ─────────────────────────────────── */
.wasm-toolbar {
  display: flex;
  align-items: center;
  gap: 0;
  min-width: 0;
}

.wasm-toolbar.hidden,
.wasm-search-info.hidden,
.wasm-search-clear.hidden {
  display: none;
}

.wasm-toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 0 0 8px;
  min-width: 0;
}

.wasm-toolbar-group + .wasm-toolbar-group {
  border-left: 1px solid #d7d7d7;
  margin-left: 8px;
}

.wasm-tb-btn {
  height: 22px;
  min-width: 24px;
  padding: 0 7px;
  border: 1px solid #b0b0b0;
  border-radius: var(--radius-sm);
  background: linear-gradient(to bottom, #ffffff, #ececec);
  color: var(--color-text);
  cursor: pointer;
  font: inherit;
}

.wasm-tb-btn:disabled {
  color: var(--color-text-disabled);
  cursor: not-allowed;
}

.wasm-zoom-level {
  min-width: 46px;
  text-align: center;
  font-size: 11px;
  color: var(--color-text-secondary);
}

.wasm-search-group {
  min-width: 0;
  max-width: 360px;
}

.wasm-search-input {
  width: 160px;
  height: 22px;
  padding: 0 8px;
  border: 1px solid #b0b0b0;
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--color-text);
  font: inherit;
}

.wasm-search-info {
  min-width: 44px;
  font-size: 11px;
  text-align: center;
  color: var(--color-text-muted);
}

/* ── 작업영역 셸 ─────────────────────────────── */
.workspace-shell {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.main-content {
  display: flex;
  height: 100%;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: linear-gradient(to bottom, #f7f7f7, #ececec);
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  padding: 12px 8px;
}

.sidebar-title {
  padding: 0 6px 10px;
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.page-thumbnails {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.qa-audit-panel {
  display: none;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #d5d8e1;
}

.qa-audit-summary,
.qa-audit-current {
  margin-bottom: 8px;
  padding: 8px;
  border: 1px solid #d7dce7;
  border-radius: var(--radius-md);
  background: linear-gradient(to bottom, #ffffff, #f6f8fc);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.qa-audit-title {
  margin-bottom: 6px;
  color: #52627d;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.qa-audit-page-label {
  display: block;
  margin-bottom: 6px;
  color: #2f456b;
  font-size: 12px;
  font-weight: 700;
}

.qa-audit-subtitle {
  margin: 8px 0 6px;
  color: #6a7990;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.qa-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.qa-chip {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border: 1px solid #cfd6e6;
  border-radius: 999px;
  background: #edf2fb;
  color: #40587f;
  font-size: 11px;
  line-height: 1;
}

.qa-chip.is-hot {
  border-color: #89a6e3;
  background: #dfe8fb;
  color: #274c9a;
}

.qa-audit-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.qa-hotspot-btn {
  width: 100%;
  padding: 8px 9px;
  border: 1px solid #cbd3e4;
  border-radius: var(--radius-md);
  background: linear-gradient(to bottom, #ffffff, #eef2f8);
  color: var(--color-text);
  text-align: left;
  cursor: pointer;
}

.qa-hotspot-btn:hover {
  border-color: #8da4d8;
  background: #e8eefb;
}

.qa-hotspot-btn.is-current {
  border-color: #5f81cf;
  background: #dfe8fb;
  box-shadow: inset 0 0 0 1px #90a9df;
}

.qa-hotspot-page {
  display: block;
  margin-bottom: 4px;
  color: #263d67;
  font-size: 12px;
  font-weight: 700;
}

.qa-hotspot-meta {
  display: block;
  color: #566579;
  font-size: 11px;
  line-height: 1.35;
}

.qa-hotspot-flags {
  display: block;
  margin-top: 3px;
  color: #304d84;
  font-size: 11px;
  line-height: 1.35;
}

.page-thumb {
  min-height: 116px;
  padding: 8px;
  border: 1px solid #c8c8c8;
  border-radius: var(--radius-md);
  background: #fefefe;
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  text-align: center;
  font-size: 11px;
  transition: border-color 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
}

.page-thumb:hover {
  border-color: #8ea6d9;
  background: #f3f6fc;
}

.page-thumb.active {
  border-color: var(--color-primary);
  background: #e7edf8;
  box-shadow: inset 0 0 0 1px #7f9bdd;
}

.page-thumb-preview {
  width: 100%;
  flex: 1;
  padding: 4px;
  overflow: hidden;
  border: 1px solid #d9d9d9;
  background: #ffffff;
  font-size: 7px;
  line-height: 1.3;
  color: #334155;
}

.workspace-main {
  flex: 1;
  min-width: 0;
  background: var(--color-editor-bg);
}

#editor-area {
  display: grid;
  grid-template-columns: var(--ruler-size) minmax(0, 1fr);
  grid-template-rows: var(--ruler-size) minmax(0, 1fr);
  height: 100%;
  width: 100%;
}

#ruler-corner {
  grid-column: 1;
  grid-row: 1;
  background: linear-gradient(135deg, #d2d2d2, #bbbbbb);
  border-right: 1px solid #999999;
  border-bottom: 1px solid #999999;
}

#h-ruler,
#v-ruler {
  display: block;
  background-color: #d3d3d3;
}

#h-ruler {
  grid-column: 2;
  grid-row: 1;
  width: 100%;
  height: var(--ruler-size);
  border-bottom: 1px solid #999999;
  background-image:
    repeating-linear-gradient(to right, rgba(0, 0, 0, 0.28) 0 1px, transparent 1px 10px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.4), rgba(0, 0, 0, 0.04));
}

#v-ruler {
  grid-column: 1;
  grid-row: 2;
  width: var(--ruler-size);
  height: 100%;
  border-right: 1px solid #999999;
  background-image:
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.28) 0 1px, transparent 1px 10px),
    linear-gradient(to right, rgba(255, 255, 255, 0.4), rgba(0, 0, 0, 0.04));
}

.viewer-panel,
.editor-panel {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
}

.viewer-panel {
  overflow: auto;
  background: #d4d4d4;
  padding: 28px 34px 34px;
}

.document-canvas {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: max-content;
  min-width: 100%;
  max-width: none;
  margin: 0 auto;
}

.viewer-panel.wasm-edit-mode {
  cursor: text;
}

.wasm-edit-caret {
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  height: 18px;
  display: none;
  border-radius: 1px;
  background: #0f4eb8;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.36);
  pointer-events: none;
  z-index: 12;
}

.wasm-edit-caret.is-active {
  display: block;
  animation: wasm-caret-blink 1.05s steps(1) infinite;
}

.wasm-ime-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  min-width: 1px;
  height: 20px;
  padding: 0;
  margin: 0;
  border: 0;
  outline: 0;
  opacity: 0;
  resize: none;
  overflow: hidden;
  background: transparent;
  color: transparent;
  pointer-events: none;
  z-index: 11;
}

@keyframes wasm-caret-blink {
  0%, 48% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.editor-panel {
  display: none;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  overflow: auto;
  background: #eeeeee;
}

.editor-toolbar-info {
  padding: 10px 12px;
  border: 1px solid #d2d7e3;
  background: #f8fbff;
  color: #47628d;
}

#quillEditor {
  background: #ffffff;
  min-height: 720px;
  box-shadow: var(--shadow-paper);
}

/* ── 공통 오버레이 ───────────────────────────── */
.drop-zone {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at top, rgba(97, 130, 214, 0.08), transparent 36%),
    linear-gradient(180deg, #f4f5f8, #dedede);
  z-index: 20;
  transition: background 0.18s ease;
}

.drop-zone.drag-over {
  background:
    radial-gradient(circle at top, rgba(97, 130, 214, 0.16), transparent 42%),
    linear-gradient(180deg, #edf2fc, #d8e0f1);
}

.drop-zone-inner {
  width: min(520px, 88vw);
  padding: 42px 38px;
  text-align: center;
  border: 1px solid #cfd8ed;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 48px rgba(26, 42, 81, 0.16);
}

.drop-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 74px;
  height: 74px;
  margin-bottom: 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, #5f7fd5, #3659a8);
  color: #ffffff;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.drop-title {
  margin-bottom: 10px;
  font-size: 18px;
  font-weight: 700;
  color: #24344f;
}

.drop-sub {
  margin-bottom: 8px;
  color: var(--color-text-secondary);
  font-size: 14px;
}

.drop-note {
  color: var(--color-text-muted);
  font-size: 12px;
}

.link-btn {
  border: 0;
  background: none;
  color: var(--color-primary-dark);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(2px);
  z-index: 50;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 5px solid #d9d9d9;
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.82s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-banner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  background: #fff1f1;
  border-bottom: 1px solid #d98c8c;
  color: #a33b3b;
  z-index: 40;
}

.error-banner .close-btn {
  border: 0;
  background: none;
  color: inherit;
  font-size: 14px;
  cursor: pointer;
}

/* ── 상태바 ──────────────────────────────────── */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--status-height);
  padding: 0 10px;
  background: var(--color-surface-raised);
  border-top: 1px solid var(--color-border-dark);
  flex-shrink: 0;
  color: var(--color-text);
  user-select: none;
}

.status-left,
.status-right {
  display: flex;
  align-items: center;
  min-width: 0;
}

.status-left {
  flex: 1;
}

.status-right {
  margin-left: auto;
  gap: 0;
  flex-shrink: 0;
}

.stb-item {
  line-height: var(--status-height);
  white-space: nowrap;
}

#statusFieldInfo {
  margin-left: 10px;
}

.stb-message {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #4c73d5;
  padding: 0 12px;
  line-height: var(--status-height);
}

.stb-divider {
  width: 1px;
  height: 14px;
  margin: 0 10px;
  background: linear-gradient(to right, #b4b4b4, #ffffff);
}

.stb-icon-btn {
  width: 24px;
  height: 24px;
  border: 1px solid transparent;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}

.stb-icon-btn:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.08);
  border-color: #b4b4b4;
}

.stb-icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.stb-zoom-val {
  min-width: 36px;
  padding: 0 4px;
  text-align: center;
  color: var(--color-text);
  line-height: 20px;
}

/* ── 스크롤바 ────────────────────────────────── */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
}

::-webkit-scrollbar-thumb {
  background: #b7b7b7;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #9f9f9f;
}

@media (max-width: 980px) {
  .sidebar {
    width: 118px;
  }

  .tb-docinfo .app-title {
    display: none;
  }

  .wasm-search-input {
    width: 120px;
  }

  .viewer-panel {
    padding: 18px;
  }
}

@media (max-width: 760px) {
  #menu-bar {
    overflow-x: auto;
  }

  #icon-toolbar {
    height: auto;
    flex-wrap: wrap;
    row-gap: 6px;
  }

  #style-bar {
    height: auto;
    flex-wrap: wrap;
    row-gap: 4px;
    padding-top: 4px;
    padding-bottom: 4px;
  }

  .sidebar {
    display: none;
  }

  #editor-area {
    grid-template-columns: 1fr;
    grid-template-rows: var(--ruler-size) minmax(0, 1fr);
  }

  #ruler-corner,
  #v-ruler {
    display: none;
  }

  #h-ruler,
  .viewer-panel,
  .editor-panel {
    grid-column: 1;
  }
}

/* 개별 HWP 페이지 래퍼 */
.hwp-page {
  background: white;
  box-shadow: var(--shadow-md);
  border-radius: 3px;
  padding: 72px 80px;            /* A4 여백 시뮬레이션 */
  margin-bottom: 24px;
  min-height: 1100px;
  position: relative;
  break-after: page;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.18s ease, outline-color 0.18s ease;
}

.hwp-page.audit-focus {
  outline: 2px solid #6488d8;
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(100, 136, 216, 0.18), var(--shadow-md);
}

.hwp-page-header {
  flex: 0 0 auto;
  position: relative;
}

.hwp-page-body {
  flex: 1 1 auto;
  position: relative;
}

.hwp-page-footer {
  margin-top: auto;
  padding-top: 18px;
  position: relative;
}

/* hwp.js 출력 내부 폰트/레이아웃 보정 */
.hwp-page * {
  font-family: 'HCR Batang', '함초롬바탕', '함초롬돋움',
               'Noto Serif KR', 'Malgun Gothic', 'Apple SD Gothic Neo', serif;
  line-height: 1.58;
  word-break: keep-all;
}

.hwp-page p   { margin-bottom: 4px; }
.hwp-page h1,
.hwp-page h2,
.hwp-page h3  { margin: 12px 0 6px; }

.hwp-page p {
  white-space: pre-wrap;
}

.hwp-page-number {
  font-size: 12px;
  letter-spacing: 0.08em;
  color: #475569;
}

.hwp-inline-image {
  display: inline-block;
  vertical-align: middle;
  margin-right: 10px;
}

.hwp-table-wrap {
  margin: 10px 0 16px;
  overflow-x: auto;
}

.hwp-page[data-source-format="hwp"] .hwp-table-wrap {
  margin: 0;
  overflow: visible;
}

.hwp-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: #fff;
  font-size: 12.7px;
  outline: 1.5px solid #374151;
  outline-offset: -1px;
}

.hwp-table[data-source-format="hwpx"] {
  outline: none;
}

.hwp-table-cell {
  border: 1px solid #6b7280;
  padding: 4px 6px;
  vertical-align: top;
  font-size: 12.7px;
  line-height: 1.32;
  white-space: normal;
}

.hwp-table[data-source-format="hwp"] .hwp-table-cell {
  box-sizing: border-box;
}

.hwp-table-paragraph {
  margin: 0;
  min-height: 1.1em;
  line-height: 1.2;
}

.hwp-table[data-source-format="hwp"] .hwp-table-paragraph {
  min-height: 0;
}

.hwp-table-paragraph + .hwp-table-paragraph {
  margin-top: 3px;
}

.hwp-table[data-source-format="hwp"] .hwp-table-paragraph + .hwp-table-paragraph {
  margin-top: 0;
}

.hwp-table-cell-content {
  position: relative;
}

.hwp-table[data-source-format="hwp"] .hwp-table-cell-content {
  min-height: 0;
}

.hwp-image-block {
  margin: 10px 0;
  text-align: center;
}

.hwp-image-block[data-align="left"] {
  text-align: left;
}

.hwp-image-block[data-align="right"] {
  text-align: right;
}

.hwp-image-block[data-inline="true"] {
  margin: 4px 0 8px;
}

.hwp-page[data-source-format="hwp"] .hwp-image-block[data-inline="true"] {
  margin: 0;
  line-height: 0;
}

.hwp-image-anchored {
  position: absolute;
  z-index: 1;
  margin: 0;
  pointer-events: none;
}

.hwp-image {
  max-width: 100%;
  height: auto;
  display: inline-block;
}

.hwp-object-block {
  margin: 8px 0;
  text-align: left;
}

.hwp-object-block[data-align="center"] {
  text-align: center;
}

.hwp-object-block[data-align="right"] {
  text-align: right;
}

.hwp-object-block[data-inline="true"] {
  margin: 4px 0 8px;
}

.hwp-equation,
.hwp-ole {
  display: inline-block;
  max-width: 100%;
  white-space: pre-wrap;
}

.hwp-equation {
  padding: 6px 10px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  font-family: 'Cambria Math', 'Times New Roman', serif;
  color: #111827;
}

.hwp-ole {
  padding: 7px 10px;
  border-radius: 8px;
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
  font-size: 12px;
}

.hwp-table-nested {
  margin-top: 6px;
}

.hwp-table-nested > .hwp-table-wrap {
  margin: 6px 0 0;
}

.hwp-textbox-block {
  margin: 6px 0;
}

.hwp-textbox-block[data-inline="true"] {
  margin: 4px 0 8px;
}

.hwp-textbox-content {
  box-sizing: border-box;
  overflow: visible;
  padding: 4px 6px;
}

.hwp-shape-block {
  display: block;
  margin: 4px 0;
}

.hwp-shape-block[data-inline="true"] {
  margin: 2px 0 4px;
}

.hwp-shape {
  display: block;
  box-sizing: border-box;
  min-width: 4px;
  min-height: 2px;
}

/* 신청서 첫 페이지 첫 표 미세 조정 */
.hwp-table[data-layout="first-page-primary"] .hwp-table-row[data-row-role="title"] > td {
  padding-top: 10px;
  padding-bottom: 10px;
  vertical-align: middle;
}

.hwp-table[data-layout="first-page-primary"] .hwp-table-row[data-row-role^="person-form"] > td,
.hwp-table[data-layout="first-page-primary"] .hwp-table-row[data-row-role^="military-form"] > td {
  padding-top: 6px;
  padding-bottom: 6px;
  vertical-align: middle;
}

.hwp-table-row[data-row-role="header"] > .hwp-table-cell {
  vertical-align: middle;
}

/* 머리행 반복: <thead> 영역 스타일 — 인쇄 시 각 페이지에서 반복 */
.hwp-table-head {
  display: table-header-group;
}

@media print {
  .hwp-table-head {
    display: table-header-group;
  }
}

.hwp-table-row[data-row-role="header"] > .hwp-table-cell .hwp-table-paragraph,
.hwp-table-cell[data-role="group-label"] .hwp-table-paragraph {
  text-align: center;
}

.hwp-table-cell[data-role="field-label"] {
  font-size: 11.8px;
  font-weight: 400;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.hwp-table-cell[data-role="field-inline-note"] {
  font-size: 11.8px;
}

.hwp-table-cell[data-role="process-period"] .hwp-table-paragraph {
  text-align: center;
}

.hwp-form-title-grid {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(282px, 1.45fr);
  align-items: center;
  column-gap: 10px;
  min-height: 74px;
}

.hwp-form-title-label {
  margin: 0;
  text-align: center;
  font-size: 19px;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.06;
  white-space: nowrap;
}

.hwp-form-title-options {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}

.hwp-form-title-option {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.04;
  font-weight: 400;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.hwp-form-header-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(220px, 42%);
  align-items: start;
  column-gap: 12px;
  width: 100%;
}

.hwp-form-header-title {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 68px;
}

.hwp-form-header-title .hwp-table-paragraph {
  margin: 0;
  text-align: center;
}

.hwp-form-header-approval {
  grid-column: 3;
  justify-self: end;
  min-width: min(100%, 280px);
  width: min(100%, 320px);
}

.hwp-form-header-approval .hwp-table-wrap {
  margin: 0;
}

/* ── HWP 엔진 WASM 렌더링 페이지 스타일 ───── */
.hwp-page-wasm {
  padding: 0;
  min-height: auto;
  overflow: hidden;
}

.hwp-page-wasm svg {
  display: block;
  width: 100%;
  height: auto;
}

/* 썸네일 WASM 미리보기 */
.page-thumb-preview-wasm {
  height: 90px;
  overflow: hidden;
  position: relative;
}

/* ── Canvas 페이지 래퍼 ──────────────────────────────────── */
.hwp-page-canvas {
  padding: 0;
  min-height: auto;
  overflow: hidden;
}

.hwp-page-canvas canvas {
  display: block;
  width: 100%;
  height: auto;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

/* 썸네일 Canvas 미리보기 */
.page-thumb-preview-canvas {
  height: 90px;
  overflow: hidden;
  background: #f8f8f8;
}
.page-thumb-preview-canvas img {
  width: 100%;
  height: auto;
  display: block;
}
