/* PDF Editor */

.pdf-editor-page .editor-page-shell {
  width: min(1680px, 96vw);
}

.editor-hero {
  max-width: 1080px;
  display: grid;
  gap: 10px;
}

.editor-hero h1 {
  max-width: none;
  font-size: clamp(34px, 4vw, 58px);
  line-height: 0.98;
}

.editor-hero .lead {
  max-width: 42ch;
  margin-top: 0;
  font-size: 18px;
}

.editor-hero-head {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.hero-utility-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-utility {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(47, 111, 227, 0.14);
  background: rgba(255, 255, 255, 0.84);
  color: #47607d;
  font-size: 13px;
  font-weight: 700;
}

.back-link {
  display: inline-block;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.file-trigger {
  cursor: pointer;
}

.editor-intro {
  margin-top: 24px;
}

.editor-drop-surface,
.editor-card {
  border: 1px solid #cfdae8;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(245, 248, 253, 0.98));
  box-shadow: 0 20px 48px rgba(19, 44, 82, 0.09);
}

.editor-drop-surface {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, 420px);
  gap: 34px;
  align-items: stretch;
  padding: 34px;
  border: 1px dashed rgba(47, 111, 227, 0.34);
  background:
    radial-gradient(circle at top left, rgba(103, 174, 255, 0.2), transparent 34%),
    linear-gradient(135deg, rgba(47, 111, 227, 0.12), rgba(255, 255, 255, 0.94));
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.editor-drop-surface:hover,
.editor-drop-surface.drag-over {
  transform: translateY(-1px);
  border-color: rgba(47, 111, 227, 0.62);
  box-shadow: 0 22px 40px rgba(47, 111, 227, 0.12);
}

.editor-drop-main {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.editor-drop-side {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  padding-left: 28px;
  border-left: 1px solid rgba(197, 213, 233, 0.86);
}

.upload-badge {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(47, 111, 227, 0.14);
  color: #38506e;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.upload-icon {
  margin-top: 22px;
}

.editor-drop-surface h2,
.editor-card h2,
.page-chip-name,
.overlay-text {
  margin: 0;
  font-family: "SF Pro Display", "Sora", "Inter", sans-serif;
  letter-spacing: -0.4px;
}

.editor-drop-surface h2 {
  margin-top: 18px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 0.98;
}

.editor-drop-surface p {
  max-width: 40ch;
  margin: 12px 0 0;
  color: #53657a;
  font-size: 17px;
}

.upload-actions {
  margin-top: 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.upload-hint {
  color: #556981;
  font-size: 14px;
  font-weight: 600;
}

.drop-side-note {
  margin: 0;
  padding-top: 16px;
  border-top: 1px solid rgba(209, 220, 236, 0.92);
  color: #58708a;
  font-size: 15px;
}

.drop-mini-steps {
  display: grid;
  gap: 10px;
}

.drop-mini-step {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #2f455c;
  font-size: 16px;
  font-weight: 700;
}

.drop-mini-step strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(41, 104, 224, 0.14), rgba(102, 176, 255, 0.18));
  color: #214fa4;
  font-size: 13px;
}

.editor-shell {
  margin-top: 24px;
}

.editor-shell-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.editor-doc-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.editor-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: minmax(232px, 272px) minmax(0, 1fr) minmax(300px, 360px);
  gap: 18px;
  align-items: start;
}

.editor-column {
  min-width: 0;
}

.editor-card {
  padding: 20px;
}

.page-column,
.tool-column {
  display: grid;
  gap: 16px;
}

.preview-column .editor-card {
  padding-bottom: 22px;
}

.card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.summary-label {
  margin: 0 0 10px;
  color: #5a6f89;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.card-copy,
.summary-note,
.field span,
.page-chip-copy,
.page-chip-meta {
  color: var(--muted);
  font-size: 14px;
}

.card-copy,
.summary-note {
  margin: 0;
}

.editor-card .summary-note + .summary-note,
.editor-card .button + .summary-note {
  margin-top: 10px;
}

.page-list {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.page-item {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid #d7dfeb;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.94);
  cursor: pointer;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.page-item:hover {
  transform: translateY(-1px);
  border-color: rgba(47, 111, 227, 0.32);
  box-shadow: 0 14px 28px rgba(47, 111, 227, 0.08);
}

.page-item.selected {
  border-color: rgba(47, 111, 227, 0.5);
  box-shadow: 0 18px 34px rgba(47, 111, 227, 0.1);
}

.page-item.dragging {
  opacity: 0.45;
}

.page-thumb-wrap {
  position: relative;
  padding: 8px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(239, 245, 255, 0.98), rgba(248, 250, 254, 0.96));
  border: 1px solid #dce5f0;
}

.page-thumb {
  width: 100%;
  display: block;
  border-radius: 10px;
  background: #ffffff;
}

.page-chip-name {
  font-size: 17px;
  overflow-wrap: anywhere;
}

.page-chip-copy {
  margin-top: 6px;
}

.page-chip-meta {
  margin-top: 8px;
}

.preview-card {
  min-height: 760px;
}

.preview-toolbar {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.workspace-text-tools {
  margin-top: 16px;
  padding: 16px 18px;
  border-radius: 22px;
  border: 1px solid rgba(209, 220, 236, 0.92);
  background: rgba(255, 255, 255, 0.92);
}

.workspace-text-tools-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.workspace-text-note {
  margin: 0;
  color: #5a6f89;
  font-size: 14px;
}

.preview-guide {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(47, 111, 227, 0.22);
  background: rgba(240, 246, 255, 0.96);
}

.preview-guide-copy {
  display: grid;
  gap: 4px;
}

.preview-guide-label {
  color: #2857a6;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.preview-guide p {
  margin: 0;
  color: #264668;
  font-size: 14px;
  font-weight: 700;
}

.preview-guide-action {
  flex-shrink: 0;
  min-width: 78px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(47, 111, 227, 0.18);
  border-radius: 12px;
  background: #ffffff;
  color: #35506f;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.preview-scroll {
  margin-top: 18px;
  min-height: 540px;
  max-height: 82vh;
  padding: 24px;
  overflow: auto;
  border-radius: 22px;
  border: 1px solid rgba(47, 111, 227, 0.14);
  background:
    linear-gradient(180deg, rgba(246, 249, 254, 0.94), rgba(239, 244, 251, 0.98));
}

.preview-stage {
  position: relative;
  width: max-content;
  margin: 0 auto;
  box-shadow: 0 18px 44px rgba(17, 35, 67, 0.12);
  border-radius: 18px;
  background: #ffffff;
}

#previewCanvas {
  display: block;
  border-radius: 18px;
}

.overlay-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.overlay-layer.placement-active {
  cursor: crosshair;
}

.preview-stage.placement-active {
  cursor: crosshair;
}

.placement-ghost,
.text-hover-highlight,
.inline-text-editor {
  position: absolute;
  z-index: 3;
}

.placement-ghost {
  width: 0;
  height: 0;
  pointer-events: none;
  opacity: 0.92;
  transform: translate(-50%, -50%);
}

.placement-ghost-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 14px 24px rgba(17, 35, 67, 0.16));
}

.text-hover-highlight {
  pointer-events: none;
  display: grid;
  align-items: start;
  justify-items: start;
  border-radius: 8px;
  border: 1px dashed rgba(47, 111, 227, 0.42);
  background: rgba(47, 111, 227, 0.08);
  box-shadow: 0 8px 18px rgba(47, 111, 227, 0.12);
}

.text-hover-badge {
  display: inline-flex;
  transform: translateY(-28px);
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(31, 76, 160, 0.96);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.overlay-item {
  position: absolute;
  cursor: grab;
  user-select: none;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: 8px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.overlay-item.selected {
  border-color: rgba(47, 111, 227, 0.38);
  box-shadow: 0 0 0 3px rgba(47, 111, 227, 0.1);
}

.overlay-item.dragging {
  cursor: grabbing;
}

.overlay-text {
  min-width: 72px;
  padding: 4px 6px;
  white-space: pre-wrap;
  line-height: 1.2;
  background: rgba(255, 255, 255, 0.88);
}

.overlay-existing-text {
  min-width: 0;
  padding: 0;
  border-radius: 8px;
  cursor: text;
  background: #ffffff;
  box-shadow: none;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
}

.inline-text-editor {
  resize: none;
  overflow: hidden;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  border: 1px solid rgba(47, 111, 227, 0.44);
  border-radius: 6px;
  background: #ffffff;
  color: #111827;
  font-family: "Manrope", "Inter", sans-serif;
  line-height: 1.1;
  box-shadow: 0 10px 24px rgba(17, 35, 67, 0.12);
  scrollbar-width: none;
}

.inline-text-input {
  overflow: clip;
  white-space: nowrap;
  text-overflow: clip;
}

.inline-text-editor:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(47, 111, 227, 0.12), 0 12px 26px rgba(17, 35, 67, 0.14);
}

.inline-text-editor::-webkit-scrollbar {
  display: none;
}

.overlay-signature {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: high-quality;
  filter: none;
}

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid rgba(206, 217, 233, 0.88);
  color: #4a6077;
}

.summary-row:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.summary-row strong {
  color: var(--text);
  font-size: 18px;
}

.signature-pad {
  width: 100%;
  height: auto;
  margin-top: 10px;
  border-radius: 18px;
  border: 1px dashed rgba(47, 111, 227, 0.32);
  background:
    linear-gradient(180deg, rgba(249, 251, 255, 0.95), rgba(243, 247, 253, 0.95));
  touch-action: none;
}

.signature-mode-switch {
  display: inline-flex;
  gap: 8px;
  margin-top: 8px;
  padding: 6px;
  border-radius: 16px;
  background: rgba(239, 244, 251, 0.96);
  border: 1px solid rgba(210, 220, 233, 0.92);
}

.signature-mode-button {
  min-width: 92px;
  height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #5b7088;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.signature-mode-button.active {
  background: #ffffff;
  color: #214fa4;
  box-shadow: 0 8px 18px rgba(47, 111, 227, 0.08);
}

.signature-panel {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.signature-stroke-field {
  margin-top: 2px;
}

.signature-style-field {
  display: grid;
  gap: 8px;
}

.signature-style-field > span {
  font-weight: 700;
}

.signature-style-list {
  display: grid;
  gap: 6px;
  padding: 8px;
  border-radius: 18px;
  border: 1px solid rgba(210, 220, 233, 0.92);
  background: #ffffff;
}

.signature-style-option {
  min-height: 56px;
  padding: 10px 16px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: #2f3849;
  font-size: 34px;
  line-height: 1;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.signature-style-option:hover {
  background: rgba(47, 111, 227, 0.08);
}

.signature-style-option.active {
  background: rgba(47, 111, 227, 0.14);
  color: #214fa4;
}

.signature-style-option[data-placeholder="true"] {
  color: #72839a;
}

.signature-style-option[data-signature-style="adobe-1"] {
  font-family: "La Belle Aurore", cursive;
  font-size: 40px;
}

.signature-style-option[data-signature-style="adobe-2"] {
  font-family: "Sacramento", cursive;
  font-size: 42px;
}

.signature-style-option[data-signature-style="adobe-3"] {
  font-family: "Nothing You Could Do", cursive;
  font-size: 30px;
}

.signature-style-option[data-signature-style="adobe-4"] {
  font-family: "Caveat", cursive;
  font-size: 38px;
  font-weight: 600;
}

.signature-actions {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.signature-helper {
  margin: 12px 0 0;
  color: #56708b;
  font-size: 14px;
}

.text-card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.text-style-panel {
  display: grid;
  gap: 14px;
  margin-top: 14px;
  padding: 14px;
  border-radius: 20px;
  border: 1px solid rgba(214, 224, 239, 0.92);
  background: rgba(255, 255, 255, 0.78);
}

.text-style-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.compact-text-style-panel {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 18px;
}

.compact-text-style-grid {
  grid-template-columns: minmax(0, 1.15fr) minmax(92px, 116px) minmax(104px, 128px) auto;
  align-items: end;
}

.compact-field textarea,
.compact-field input[type="text"],
.compact-field input[type="number"],
.compact-field select {
  min-height: 48px;
}

.text-style-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  align-self: end;
}

.style-toggle {
  min-width: 46px;
  height: 42px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid #d6e0ef;
  background: #ffffff;
  color: #35506f;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

.style-toggle:hover:not([disabled]) {
  transform: translateY(-1px);
  border-color: rgba(47, 111, 227, 0.32);
  box-shadow: 0 12px 24px rgba(47, 111, 227, 0.08);
}

.style-toggle.active {
  background: #2456a5;
  border-color: #2456a5;
  color: #ffffff;
}

.selected-item-fields {
  display: grid;
  gap: 14px;
}

.selection-note {
  margin: 0;
}

.selection-note kbd {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid #d3dce9;
  border-radius: 8px;
  background: #ffffff;
  color: #314961;
  font-size: 12px;
  font-weight: 700;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-weight: 700;
}

.field textarea,
.field input[type="text"],
.field input[type="number"],
.field select,
.field input[type="range"],
.field input[type="color"] {
  width: 100%;
}

.field textarea,
.field input[type="text"],
.field input[type="number"],
.field select {
  min-height: 104px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid #d7dfeb;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

.field textarea {
  resize: vertical;
}

.field input[type="text"],
.field input[type="number"],
.field select {
  min-height: 48px;
}

.field input[type="color"] {
  height: 44px;
  padding: 0;
  border: 1px solid #d7dfeb;
  border-radius: 14px;
  background: #ffffff;
}

.color-field input[type="color"] {
  min-width: 74px;
}

.field input[type="range"] {
  accent-color: var(--accent);
}

.icon-button {
  min-width: 42px;
  height: 42px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid #d6e0ef;
  background: #ffffff;
  color: #35506f;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.icon-button.icon-only {
  min-width: 42px;
  width: 42px;
  padding: 0;
}

.icon-button.icon-only svg {
  width: 20px;
  height: 20px;
}

.icon-button:hover:not([disabled]),
.file-trigger:hover,
.button:hover:not([disabled]) {
  transform: translateY(-1px);
}

.icon-button:hover:not([disabled]) {
  border-color: rgba(47, 111, 227, 0.32);
  box-shadow: 0 12px 24px rgba(47, 111, 227, 0.08);
}

.icon-button[disabled],
.button[disabled],
.style-toggle[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

.remove-button {
  color: #9a3c3c;
}

.status-banner {
  margin: 0;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(47, 111, 227, 0.14);
  color: #41556e;
  font-size: 14px;
  font-weight: 700;
}

.status-banner[data-tone="success"] {
  border-color: rgba(31, 162, 97, 0.18);
  background: rgba(239, 251, 245, 0.92);
  color: #1a6b48;
}

.status-banner[data-tone="error"] {
  border-color: rgba(202, 73, 73, 0.2);
  background: rgba(255, 243, 243, 0.96);
  color: #9b2f2f;
}

.status-banner[data-tone="working"] {
  border-color: rgba(47, 111, 227, 0.24);
  background: rgba(240, 246, 255, 0.96);
  color: #2456a5;
}

.hidden {
  display: none !important;
}

@media (max-width: 1180px) {
  .pdf-editor-page .editor-page-shell {
    width: min(1120px, 92vw);
  }

  .editor-drop-surface {
    grid-template-columns: 1fr;
  }

  .editor-drop-side {
    padding-left: 0;
    border-left: 0;
    padding-top: 4px;
  }

  .editor-grid {
    grid-template-columns: 1fr;
  }

  .compact-text-style-grid,
  .text-style-grid {
    grid-template-columns: 1fr;
  }

  .preview-card {
    min-height: 0;
  }

  .workspace-text-tools-head {
    flex-direction: column;
  }
}

@media (max-width: 760px) {
  .editor-drop-surface,
  .editor-card,
  .preview-scroll,
  .preview-stage {
    border-radius: 24px;
  }

  .editor-drop-surface,
  .editor-card {
    padding: 18px;
  }

  .preview-guide {
    align-items: stretch;
    flex-direction: column;
  }

  .preview-guide-action {
    width: 100%;
  }

  .text-hover-badge {
    transform: translateY(-22px);
  }

  .preview-scroll {
    padding: 14px;
  }

  .page-item {
    grid-template-columns: 72px minmax(0, 1fr);
  }
}
