/* PDF Color Remover 레이아웃 — M-Pick 내신왕 디자인 시스템 토큰만 사용 (모서리 0, 그림자 없음, 선으로 구분) */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--ui-surface); }
h2 { margin: 0; }
.section-title { font-size: 16px; font-weight: 650; line-height: 1.5; margin: 0; }
.caption { font-size: 13px; line-height: 1.6; font-weight: 400; color: var(--ui-sub); }
input[type=checkbox], input[type=radio] { accent-color: var(--ui-accent); width: 16px; height: 16px; margin: 3px 0 0; flex: none; }

/* 헤더 */
.topbar { min-height: 72px; display: flex; align-items: center; gap: var(--ui-space-6); padding: 0 var(--ui-space-8);
  border-bottom: 1px solid var(--ui-line); position: sticky; top: 0; background: var(--ui-surface); z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.4; white-space: nowrap; }
.brand img { width: 32px; height: 32px; flex: none; }
.docinfo { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 2단 레이아웃: 320px 설정 패널 + 미리보기 */
.layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: var(--ui-space-8); padding: 0 var(--ui-space-8);
  height: calc(100vh - 73px); }
.panel { overflow-y: auto; padding: var(--ui-space-6) var(--ui-space-1) 0 0; display: flex; flex-direction: column; }
.block { padding: 0 0 var(--ui-space-6); margin-bottom: var(--ui-space-6); border-bottom: 1px solid var(--ui-line); display: grid; gap: var(--ui-space-3); }
.block-head { display: flex; align-items: center; justify-content: space-between; }
.stack { display: grid; gap: var(--ui-space-4); }
.stack-sm { display: grid; gap: var(--ui-space-2); }
.sub { padding-left: var(--ui-space-6); }
.row { display: flex; align-items: center; gap: var(--ui-space-2); }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid2, .grid3, .grid4 { display: grid; gap: var(--ui-space-2); }
.grid2 { grid-template-columns: 1fr 1fr; } .grid3 { grid-template-columns: repeat(3, 1fr); } .grid4 { grid-template-columns: repeat(4, 1fr); }
.field .input, .field select { width: 100%; min-width: 0; }
.field > .row { font-weight: 400; }
.check { display: flex; align-items: flex-start; gap: var(--ui-space-2); font-size: 14px; line-height: 1.5; cursor: pointer; }
.check.strong { font-weight: 600; }
.check.strong .caption { display: block; font-weight: 400; margin-top: 2px; }
.is-off { opacity: .45; pointer-events: none; }
.is-off :is(input, select, button) { pointer-events: none; }

/* 색 입력과 대상 색 칩 */
.swatch-input { width: var(--ui-control-compact); height: var(--ui-control-compact); padding: 2px; border: 1px solid var(--ui-line-strong);
  border-radius: var(--ui-radius-none); background: var(--ui-surface); cursor: pointer; }
.swatch-input::-webkit-color-swatch-wrapper { padding: 0; }
.swatch-input::-webkit-color-swatch { border: 0; border-radius: var(--ui-radius-none); }
.chips { display: flex; flex-wrap: wrap; gap: var(--ui-space-2); min-height: var(--ui-control-compact); }
.chip { display: inline-flex; align-items: center; gap: var(--ui-space-2); min-height: var(--ui-control-compact); padding: 0 4px 0 10px;
  border: 1px solid var(--ui-line); font: 500 13px var(--font-mono); color: var(--ui-ink); background: var(--ui-surface); }
.chip i { width: 14px; height: 14px; border: 1px solid var(--ui-line-strong); flex: none; }
.chip button { border: 0; background: none; width: 28px; height: 28px; cursor: pointer; color: var(--ui-sub); font-size: 16px; line-height: 1; }
.chip button:hover { background: var(--ui-surface-ghost-hover); color: var(--ui-ink); }
.chip button:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 0; }
.chips .caption { align-self: center; }

/* 내보내기 */
.exportbar { position: sticky; bottom: 0; background: var(--ui-surface); padding: var(--ui-space-4) 0 var(--ui-space-6);
  border-top: 1px solid var(--ui-line); margin-top: auto; display: grid; gap: var(--ui-space-3); }
.btn.wide { width: 100%; }
.bar { height: 8px; background: var(--ui-surface-muted); border: 1px solid var(--ui-line); }
.bar span { display: block; height: 100%; width: 0; background: var(--ui-accent); transition: width .25s; }

/* 미리보기 */
.viewer { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-left: 1px solid var(--ui-line); padding-left: var(--ui-space-8); }
.toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--ui-space-4); flex-wrap: wrap; border-bottom: 1px solid var(--ui-line); }
.toolbar .tabs { border-bottom: 0; }
.tools { padding-bottom: 6px; flex-wrap: wrap; }
.tools select { min-height: var(--ui-control-compact); padding: 4px 8px; }
.pagebox { width: 72px; min-height: var(--ui-control-compact); padding: 4px 8px; text-align: center; }
.statusline { display: flex; gap: var(--ui-space-4); align-items: center; flex-wrap: wrap; min-height: 44px; padding: var(--ui-space-2) 0; font-size: 14px; }
.statusline.is-error #status { color: var(--ui-danger); font-weight: 600; }
.statusline.is-busy #status::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px;
  border: 2px solid var(--ui-accent-soft); border-top-color: var(--ui-accent); border-radius: var(--ui-radius-full); animation: mp-spin .65s linear infinite; }
@media (prefers-reduced-motion: reduce) { .statusline.is-busy #status::before { animation: none; } }
.stage { flex: 1; min-height: 0; overflow: auto; background: var(--ui-surface-muted); border: 1px solid var(--ui-line);
  display: flex; gap: var(--ui-space-4); align-items: flex-start; justify-content: center; padding: var(--ui-space-4); margin-bottom: var(--ui-space-6); }
.stage.zoomed { justify-content: flex-start; }
.stage figure { margin: 0; display: grid; gap: var(--ui-space-1); flex: 0 1 auto; min-width: 0; }
.stage.fit figure { max-height: 100%; }
.stage.both figure { flex: 1 1 0; }
.stage figcaption { text-align: left; }
.stage canvas { display: block; background: var(--ui-surface); border: 1px solid var(--ui-line); }
#cvOrig { cursor: crosshair; }
.stage.stale canvas { opacity: .6; }
.empty { align-self: center; text-align: center; padding: var(--ui-space-8); border: 1px dashed var(--ui-line-strong); background: var(--ui-surface); }
.empty p { margin: 0 0 var(--ui-space-2); }
.dropmask { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(36, 33, 38, .35); z-index: 20; }
.dropmask span { background: var(--ui-surface); border: 2px solid var(--ui-accent); padding: var(--ui-space-6) var(--ui-space-8); font-size: 18px; font-weight: 650; }
body.dragging .dropmask { display: flex; }

@media (max-width: 1100px) { .topbar, .layout { padding-left: var(--ui-space-6); padding-right: var(--ui-space-6); } .layout { gap: var(--ui-space-6); } .viewer { padding-left: var(--ui-space-6); } }
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; height: auto; padding: 0 var(--ui-space-5, 20px); }
  .panel { overflow: visible; padding-right: 0; }
  .viewer { border-left: 0; padding-left: 0; min-height: 80vh; }
  .stage { min-height: 60vh; }
}
@media (max-width: 560px) { .topbar, .layout { padding-left: var(--ui-space-4); padding-right: var(--ui-space-4); } .docinfo { display: none; } }
