/* ---------- 3. PDF 편집하기 ---------- */
.pdf-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.pdf-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.pdf-work { min-width: 0; }
.pdf-field { display: block; margin: 0 0 10px; font-size: 13px; font-weight: 700; }
.pdf-field input[type="text"], .pdf-field input:not([type]) {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 400;
}
.pdf-check { display: flex; align-items: flex-start; gap: 6px; margin-top: 12px; font-size: 13px; }
.pdf-check input { margin-top: 3px; }
.pdf-opt-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pdf-opt-row select {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.pdf-private { color: var(--brand-deep); }
.pdf-bar .btn { white-space: nowrap; }
.pdf-count { font-size: 13px; color: var(--brand-deep); }
.pdf-tip { flex-basis: 100%; margin: 0; }

/* empty state + drop frame */
.pdf-empty {
  padding: 56px 16px;
  text-align: center;
  background: var(--surface);
  border: 2px dashed var(--line);
  border-radius: 12px;
}
.pdf-empty img { width: 72px; height: 72px; border-radius: 50%; background: #fff; opacity: .9; }
.pdf-empty p { margin: 10px 0 0; }
#tool-pdf.is-dropping::before,
#tool-pdf.is-dropping::after { position: fixed; z-index: 20; pointer-events: none; }
#tool-pdf.is-dropping::before {
  content: "";
  inset: 12px;
  border: 3px dashed var(--brand);
  border-radius: 16px;
  background: color-mix(in srgb, var(--brand-soft) 80%, transparent);
}
#tool-pdf.is-dropping::after {
  content: "여기에 놓으면 쪽이 추가돼요";
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 14px 24px;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: var(--shadow);
}

/* page grid */
.pdf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.pdf-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 8px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 12px;
  user-select: none;
  -webkit-user-select: none;
}
.pdf-card.is-sel { border-color: var(--brand); background: var(--brand-soft); }
.pdf-card.is-dragging { opacity: .35; }
.pdf-card.drop-before { box-shadow: -5px 0 0 0 var(--brand); }
.pdf-card.drop-after { box-shadow: 5px 0 0 0 var(--brand); }
.pdf-thumb {
  position: relative;
  display: grid;
  place-items: center;
  height: 180px;
  background: var(--desk);
  border-radius: 8px;
  overflow: hidden;
  cursor: grab;
}
.pdf-thumb canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  background: #fff;
  box-shadow: 0 1px 4px rgb(0 0 0 / 25%);
}
.pdf-num {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1;
  min-width: 24px;
  padding: 0 7px;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 24px;
  text-align: center;
}
:root[data-theme="dark"] .pdf-num { color: #0b1a2b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pdf-num { color: #0b1a2b; } }
.pdf-pick {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgb(255 255 255 / 85%);
  cursor: pointer;
}
.pdf-pick input { width: 18px; height: 18px; margin: 0; cursor: pointer; accent-color: var(--brand); }
.pdf-edited {
  position: absolute;
  left: 4px;
  bottom: 4px;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  font-size: 11px;
}
.pdf-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--muted);
}
.pdf-card-tools { display: flex; justify-content: space-between; gap: 2px; }
.pdf-card-tools button {
  flex: 1;
  min-width: 0;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.pdf-card-tools button:hover { border-color: var(--brand); }
.pdf-card-tools button.del { color: var(--danger); }
.pdf-ghost {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  opacity: .85;
  box-shadow: var(--shadow);
  background: #fff;
  border: 2px solid var(--brand);
}
.pdf-ghost canvas { display: block; width: 100%; height: auto; }
.pdf-ghost b {
  position: absolute;
  right: -8px;
  top: -8px;
  min-width: 24px;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  line-height: 24px;
  text-align: center;
  font-size: 13px;
}

/* busy */
.pdf-busy {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: rgb(0 0 0 / 35%);
}
.pdf-busy-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  font-weight: 700;
}
.pdf-spin {
  width: 20px;
  height: 20px;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: pdf-spin .8s linear infinite;
}
@keyframes pdf-spin { to { transform: rotate(360deg); } }

/* editor */
.pdf-editor {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.pdf-ed-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.pdf-ed-group { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pdf-ed-right { margin-left: auto; }
.pdf-ed-bar .btn.is-on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-deep); font-weight: 700; }
.pdf-ed-bar .btn.primary { color: #fff; }
:root[data-theme="dark"] .pdf-ed-bar .btn.primary { color: #0b1a2b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pdf-ed-bar .btn.primary { color: #0b1a2b; } }
.pdf-ed-opts label { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }
.pdf-ed-opts input[type="color"] { width: 36px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; }
.pdf-ed-opts input[type="number"] {
  width: 64px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.pdf-ed-hint { margin: 0; padding: 6px 12px; background: var(--hint-fill); }
.pdf-ed-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px;
  background: var(--desk);
}
.pdf-ed-stage {
  position: relative;
  margin: 0 auto;
  background: #fff;
  box-shadow: var(--shadow);
}
.pdf-ed-stage canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
#pdf-ed-fg { touch-action: none; }
#pdf-ed-ta {
  position: absolute;
  z-index: 3;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 2px dashed var(--brand);
  outline-offset: 1px;
  background: rgb(128 128 128 / 22%);
  font-family: "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  line-height: 1.3;
  resize: none;
  overflow: hidden;
  white-space: pre;
}

/* ---------- narrow screens ---------- */
@media (max-width: 900px) {
  .pdf-layout { grid-template-columns: minmax(0, 1fr); }
  .pdf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .pdf-thumb { height: 150px; }
  .pdf-ed-right { margin-left: 0; }
}
