.annotation-canvas {
  position: absolute;
  inset: 0;
  touch-action: none;
  cursor: crosshair;
}

.annotation-selection {
  position: absolute;
  pointer-events: none;
  outline: 2px dashed #e34d32;
  outline-offset: 3px;
}

.resize-handle {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: #e34d32;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  cursor: nwse-resize;
  border-radius: 2px;
}

.inline-text {
  position: absolute;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 2px dashed #e34d32;
  background: #fffffffa;
  color: #101416;
  font-family: Arial, sans-serif;
  resize: both;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  box-sizing: border-box;
  min-width: 40px;
  min-height: 24px;
  z-index: 25;
}

.inline-text-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #e34d32;
  border: 2px solid #ffffff;
  border-radius: 2px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  cursor: nwse-resize;
  z-index: 26;
  touch-action: none;
}

.annotation-options {
  padding: 0 20px;
  height: 46px;
  min-height: 46px;
  max-height: 46px;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 12px;
  font-size: 13px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  overflow: hidden;
}

.highlight-color-block {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.highlight-color-block[hidden] {
  display: none !important;
}

.color-picker-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.color-picker-wrapper label {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}

.color-input-container {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  border: 2px solid #ffffff;
  cursor: pointer;
}

.annotation-options input[type="color"] {
  position: absolute;
  inset: -6px;
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0;
  border: none;
  cursor: pointer;
  background: transparent;
}

.swatches-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: var(--swatch-color);
  border: 2px solid #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}

.swatch-btn:hover {
  transform: scale(1.18);
}

.swatch-btn.active {
  box-shadow: 0 0 0 2px #0e1217, 0 2px 4px rgba(0, 0, 0, 0.2);
  transform: scale(1.1);
}

.shape-color-block {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.shape-color-block[hidden] {
  display: none !important;
}

.shape-swatch-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: var(--swatch-color);
  border: 2px solid #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}

.shape-swatch-btn:hover {
  transform: scale(1.18);
}

.shape-swatch-btn.active {
  box-shadow: 0 0 0 2px #0e1217, 0 2px 4px rgba(0, 0, 0, 0.2);
  transform: scale(1.1);
}

.options-divider {
  width: 1px;
  height: 18px;
  background: #e2e8f0;
}

.annotation-options span,
.options-hint {
  color: #64748b;
  font-size: 12px;
}

.pdf-page {
  flex-shrink: 0;
  margin-inline: auto;
}

.page-stage {
  justify-content: flex-start;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.editor-note {
  font-size: 12px;
  line-height: 1.5;
  color: #64748b;
}

.doc-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 600px) {
  .editor-topbar {
    flex-wrap: wrap;
    height: auto;
    padding-block: 10px;
  }
  .editor-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .canvas-toolbar {
    padding-inline: 8px;
  }
  .annotation-options {
    padding-inline: 10px;
  }
}

/* ==========================================================================
   Download Countdown Modal
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(14, 18, 23, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: modalFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop[hidden] {
  display: none !important;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 20px 50px -12px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(15, 23, 42, 0.08);
  padding: 32px 28px 28px;
  text-align: center;
  animation: modalScaleIn 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleIn {
  from {
    transform: scale(0.93) translateY(10px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.modal-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  display: grid;
  place-items: center;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
}

.modal-close-btn:hover {
  background: #e2e8f0;
  color: #0e1217;
  transform: scale(1.06);
}

.modal-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 24px;
}

.modal-badge-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #16a34a;
  display: grid;
  place-items: center;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.12);
}

.modal-header h3 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #0e1217;
  margin: 0 0 4px;
}

.modal-subtitle {
  font-size: 13px;
  color: #64748b;
  margin: 0;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* State 1: Countdown Loader */
.download-countdown-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.download-countdown-container[hidden] {
  display: none !important;
}

.countdown-loader-wrapper {
  position: relative;
  width: 110px;
  height: 110px;
  display: grid;
  place-items: center;
}

.countdown-progress-ring {
  transform: rotate(-90deg);
}

.countdown-progress-ring .ring-bg {
  stroke: #e2e8f0;
}

.countdown-progress-ring .ring-fill {
  stroke: #16a34a;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.85s linear;
}

.countdown-number-display {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.countdown-number {
  font-family: 'DM Mono', monospace;
  font-size: 34px;
  font-weight: 800;
  color: #0e1217;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
  animation: countdownPulse 1s infinite alternate;
}

@keyframes countdownPulse {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}

.countdown-unit {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  margin-top: 2px;
}

.countdown-status {
  text-align: center;
}

.status-primary {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 4px;
}

.status-secondary {
  font-size: 12px;
  color: #64748b;
  margin: 0;
}

.status-secondary strong {
  color: #16a34a;
  font-weight: 700;
}

/* State 2: Ready State */
.download-ready-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: readyFadeIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.download-ready-container[hidden] {
  display: none !important;
}

@keyframes readyFadeIn {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.ready-icon-wrapper {
  margin-bottom: 2px;
}

.ready-check-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #f0fdf4;
  border: 2px solid #86efac;
  color: #16a34a;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 14px rgba(34, 197, 94, 0.2);
  animation: checkPop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes checkPop {
  0% { transform: scale(0.5); opacity: 0; }
  70% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.ready-status h4 {
  font-size: 18px;
  font-weight: 800;
  color: #0e1217;
  margin: 0 0 4px;
}

.ready-status p {
  font-size: 13px;
  color: #64748b;
  margin: 0;
}

.ready-download-btn {
  width: 100%;
  height: 48px;
  margin-top: 8px;
  font-size: 15px;
  font-weight: 800;
  justify-content: center;
  border-radius: 12px;
  background: #dff55f;
  color: #0e1217;
  border: 1px solid #d2ee44;
  box-shadow: 0 4px 14px rgba(223, 245, 95, 0.35);
  transition: all 0.16s ease;
}

.ready-download-btn:hover {
  background: #d2ee44;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(223, 245, 95, 0.45);
}

.ready-download-btn:active {
  transform: translateY(1px);
}

/* ==========================================================================
   Modals & Workflows (Merge, Compress, Sign)
   ========================================================================== */
.modal-card-lg {
  max-width: 560px !important;
  text-align: left;
}

.modal-card-lg .modal-header {
  text-align: center;
}

.modal-hint-text {
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}

/* Merge Modal */
.merge-file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.merge-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13.5px;
}

.merge-file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.merge-file-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e2e8f0;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #475569;
  flex-shrink: 0;
}

.merge-file-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

.merge-file-meta {
  font-size: 11.5px;
  color: #64748b;
}

.merge-file-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-icon-xs {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #64748b;
  transition: all 0.15s ease;
}

.btn-icon-xs:hover:not(:disabled) {
  background: #f1f5f9;
  color: #0e1217;
  border-color: #cbd5e1;
}

.btn-icon-xs:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.merge-dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 20px 16px;
  background: #f8fafc;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.merge-dropzone:hover {
  border-color: #0ea5e9;
  background: #f0f9ff;
}

.merge-dropzone p {
  font-size: 13.5px;
  color: #64748b;
  margin: 6px 0 0;
}

.link-btn {
  background: none;
  border: none;
  color: #0284c7;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
}

/* Compress Modal */
.compress-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.compress-preset {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  background: #ffffff;
  transition: all 0.15s ease;
}

.compress-preset:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.compress-preset.active {
  border-color: #0e1217;
  background: #f8fafc;
  box-shadow: 0 0 0 1px #0e1217;
}

.preset-info strong {
  display: block;
  font-size: 13.5px;
  color: #0e1217;
}

.preset-info small {
  font-size: 11.5px;
  color: #64748b;
}

.preset-badge {
  font-size: 11px;
  font-family: 'DM Mono', monospace;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.compress-progress-wrap {
  margin-top: 14px;
}

.compress-progress-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.compress-progress-fill {
  height: 100%;
  background: #22c55e;
  transition: width 0.2s ease;
}

.compress-progress-text {
  font-size: 12px;
  color: #64748b;
  margin-top: 6px;
  text-align: center;
}

.compress-result-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 12px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  margin-top: 12px;
  font-size: 13px;
}

.saved-pill {
  background: #16a34a;
  color: #ffffff;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 12px;
}

/* Sign Modal */
.sig-nav-tabs {
  display: flex;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 16px;
  gap: 6px;
}

.sig-tab-btn {
  background: none;
  border: none;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
}

.sig-tab-btn:hover {
  color: #0e1217;
}

.sig-tab-btn.active {
  color: #0e1217;
  border-bottom-color: #0e1217;
}

.sig-canvas-wrapper {
  position: relative;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #ffffff;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.03);
}

#sigCanvas {
  display: block;
  width: 100%;
  height: 160px;
  cursor: crosshair;
  touch-action: none;
}

.sig-baseline {
  position: absolute;
  bottom: 30px;
  left: 24px;
  right: 24px;
  height: 1px;
  border-bottom: 1px dashed #cbd5e1;
  pointer-events: none;
}

.sig-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}

.sig-colors {
  display: flex;
  gap: 6px;
}

.sig-color-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sig-color-btn.active {
  box-shadow: 0 0 0 2px #0ea5e9;
  transform: scale(1.1);
}

.btn-text-sm {
  background: none;
  border: none;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  padding: 4px 8px;
}

.btn-text-sm:hover {
  color: #ef4444;
}

.sig-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  box-sizing: border-box;
}

.sig-input:focus {
  outline: none;
  border-color: #0e1217;
}

.sig-type-preview-box {
  padding: 24px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  min-height: 90px;
  display: grid;
  place-items: center;
  margin-bottom: 12px;
}

.sig-type-preview {
  font-size: 34px;
  color: #101416;
  user-select: none;
  font-style: italic;
  font-family: 'Brush Script MT', 'Dancing Script', cursive, sans-serif;
}

.sig-font-options {
  display: flex;
  gap: 8px;
}

.sig-font-btn {
  flex: 1;
  padding: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  background: #ffffff;
  transition: all 0.15s ease;
}

.sig-font-btn.active {
  background: #0e1217;
  color: #ffffff;
  border-color: #0e1217;
}

/* Monetag Direct Link Sponsor UI */
.direct-link-container {
  margin-top: 1rem;
  width: 100%;
  display: flex;
  justify-content: center;
}

.direct-link-anchor {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.95rem;
  background: rgba(14, 18, 23, 0.04);
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.8rem;
  color: #475569;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.direct-link-anchor:hover {
  background: rgba(0, 113, 227, 0.08);
  border-color: #0071e3;
  color: #0071e3;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 113, 227, 0.1);
}

.direct-link-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: rgba(0, 113, 227, 0.15);
  color: #0071e3;
  letter-spacing: 0.03em;
}

.direct-link-label {
  font-weight: 600;
}

