/* ==========================================================================
   PDF Fácil — Mock visual estático (Fase A)
   ========================================================================== */

:root {
  /* Cor de destaque */
  --accent: #E5484D;
  --accent-hover: #D33438;
  --accent-active: #B92329;
  --accent-tint: #FDEDEE;
  --accent-tint-strong: #FBD8D9;

  /* Neutros */
  --bg-app: #F7F7F8;
  --surface: #FFFFFF;
  --surface-canvas: #ECECEE;
  --border: #E4E4E7;
  --border-strong: #D4D4D8;
  --text-primary: #18181B;
  --text-secondary: #71717A;
  --text-tertiary: #A1A1AA;
  --text-on-accent: #FFFFFF;

  --info-blue: #2563EB;
  --info-blue-tint: #EFF6FF;

  /* Espaçamento */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-6: 24px;

  /* Raios */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  /* Sombras */
  --shadow-sm: 0 1px 2px rgba(24, 24, 27, 0.06), 0 1px 1px rgba(24, 24, 27, 0.04);
  --shadow-md: 0 4px 12px rgba(24, 24, 27, 0.08), 0 2px 4px rgba(24, 24, 27, 0.04);
  --shadow-lg: 0 16px 40px rgba(24, 24, 27, 0.16), 0 4px 10px rgba(24, 24, 27, 0.06);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button {
  font-family: inherit;
}

a {
  color: inherit;
}

svg {
  display: block;
  flex-shrink: 0;
}

.hidden {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ==========================================================================
   Tela 1 — Home
   ========================================================================== */

#screen-home {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6);
}

.home-wrap {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--sp-6);
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.brand-mark .logo-icon {
  width: 34px;
  height: 34px;
  color: var(--accent);
}

.brand-mark span {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.5;
  max-width: 420px;
}

.home-actions {
  display: flex;
  gap: var(--sp-3);
  width: 100%;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .05s ease;
  white-space: nowrap;
}

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

.btn svg {
  width: 18px;
  height: 18px;
}

.btn-lg {
  padding: 14px 20px;
  font-size: 15px;
  border-radius: var(--radius-md);
  flex: 1;
}

.btn-primary {
  background: var(--accent);
  color: var(--text-on-accent);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-primary:active {
  background: var(--accent-active);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-tint);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--bg-app);
  color: var(--text-primary);
}

.btn-danger-subtle {
  background: var(--accent-tint);
  color: var(--accent-active);
  border-color: transparent;
}

.btn-danger-subtle:hover {
  background: var(--accent-tint-strong);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

.btn-icon:hover {
  background: var(--bg-app);
  color: var(--text-primary);
}

.btn-icon[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.dropzone {
  width: 100%;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 40px var(--sp-6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-tint);
}

.dropzone .upload-icon {
  width: 40px;
  height: 40px;
  color: var(--text-tertiary);
  margin-bottom: var(--sp-2);
  transition: color .15s ease;
}

.dropzone:hover .upload-icon,
.dropzone.dragover .upload-icon {
  color: var(--accent);
}

.dropzone-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.dropzone-sub {
  font-size: 13px;
  color: var(--text-secondary);
}

.home-footer {
  font-size: 12.5px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

.home-footer svg {
  width: 14px;
  height: 14px;
  color: var(--text-tertiary);
}

/* ==========================================================================
   Tela 2 — Editor
   ========================================================================== */

#screen-editor {
  height: 100vh;
  display: grid;
  grid-template-columns: 180px 1fr 240px;
  grid-template-rows: 56px 1fr;
  grid-template-areas:
    "toolbar toolbar toolbar"
    "sidebar canvas  props";
}

/* --- Toolbar --- */

.toolbar {
  grid-area: toolbar;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-4);
  gap: var(--sp-4);
  min-width: 0;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-shrink: 0;
}

.doc-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.toolbar-center {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  overflow-x: auto;
  flex: 1;
  justify-content: center;
  min-width: 0;
}

.tool-sep {
  width: 1px;
  height: 28px;
  background: var(--border);
  margin: 0 var(--sp-1);
  flex-shrink: 0;
}

.tool-btn-wrap {
  position: relative;
  flex-shrink: 0;
}

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  transition: background-color .15s ease, color .15s ease;
}

.tool-btn svg {
  width: 20px;
  height: 20px;
}

.tool-btn:hover {
  background: var(--bg-app);
  color: var(--text-primary);
}

.tool-btn.active {
  background: var(--accent-tint);
  color: var(--accent);
}

.tool-btn-chevron {
  display: flex;
  align-items: center;
  gap: 2px;
}

.tool-btn-chevron svg.chev {
  width: 10px;
  height: 10px;
  margin-top: 1px;
}

.tool-dropdown {
  /* fixed + posição calculada em JS ao abrir: imune ao clipping do
     overflow:auto da .toolbar-center (que recortava o menu). */
  position: fixed;
  top: 0;
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  min-width: 190px;
  padding: var(--sp-2);
  z-index: 40;
}

.tool-dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.tool-dropdown-item:hover {
  background: var(--bg-app);
}

.tool-dropdown-item svg {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
}

/* --- Sidebar de páginas --- */

.sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-header {
  padding: var(--sp-4) var(--sp-4) var(--sp-2);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
}

.sidebar-pages {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--sp-4) var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.page-thumb-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.page-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4.24;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  cursor: pointer;
  overflow: hidden;
  padding: 10% 12%;
  display: flex;
  flex-direction: column;
  gap: 10%;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.page-thumb:hover {
  border-color: var(--accent);
}

.page-thumb.selected {
  border: 2px solid var(--accent);
  padding: calc(10% - 1px) calc(12% - 1px);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.thumb-line {
  height: 8%;
  background: var(--border-strong);
  border-radius: 2px;
}

.thumb-line.short {
  width: 55%;
}

.thumb-line.heading {
  height: 12%;
  width: 70%;
  background: var(--text-tertiary);
  margin-bottom: 4%;
}

.page-thumb-actions {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 3px;
  opacity: 0;
  transition: opacity .12s ease;
}

.page-thumb:hover .page-thumb-actions {
  opacity: 1;
}

.thumb-action-btn {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.thumb-action-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.thumb-action-btn svg {
  width: 12px;
  height: 12px;
}

.page-number {
  font-size: 11.5px;
  color: var(--text-secondary);
  font-weight: 500;
}

.add-page-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px;
  border: 2px dashed var(--border-strong);
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background-color .15s ease;
}

.add-page-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-tint);
}

.add-page-btn svg {
  width: 14px;
  height: 14px;
}

/* --- Área central / canvas --- */

.canvas-area {
  grid-area: canvas;
  background: var(--surface-canvas);
  overflow: auto;
  display: flex;
  justify-content: center;
  padding: 48px 24px;
  min-width: 0;
}

.page-doc {
  position: relative;
  width: 535px;   /* 595 * .9 */
  height: 758px;  /* 842 * .9 */
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  border-radius: 2px;
  flex-shrink: 0;
  padding: 56px 52px;
}

.doc-heading-bar {
  height: 18px;
  width: 62%;
  background: var(--text-primary);
  opacity: 0.85;
  border-radius: 3px;
  margin-bottom: 28px;
}

.doc-text-bar {
  height: 9px;
  background: var(--border-strong);
  border-radius: 3px;
  margin-bottom: 12px;
}

.doc-text-bar.w-100 { width: 100%; }
.doc-text-bar.w-95  { width: 95%; }
.doc-text-bar.w-88  { width: 88%; }
.doc-text-bar.w-70  { width: 70%; }
.doc-text-bar.w-60  { width: 60%; }
.doc-text-bar.w-80  { width: 80%; }

.doc-paragraph-gap {
  height: 18px;
}

/* Editable-content hint on an existing text bar */

.doc-text-bar.editable-hint {
  position: relative;
  border: 1.5px dashed var(--info-blue);
  background: var(--info-blue-tint);
  outline: 4px solid transparent;
}

.edit-hint-chip {
  position: absolute;
  top: -30px;
  left: 0;
  background: var(--text-primary);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 6px;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}

.edit-hint-chip::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 14px;
  width: 8px;
  height: 8px;
  background: var(--text-primary);
  transform: rotate(45deg);
}

/* Overlay objects */

.overlay-obj {
  position: absolute;
  cursor: move;
}

.overlay-text {
  top: 210px;
  left: 60px;
  width: 190px;
  padding: 8px 10px;
  font-size: 15px;
  font-weight: 600;
  color: #1E3A8A;
  background: rgba(255, 255, 255, 0.4);
}

.overlay-image {
  top: 340px;
  left: 300px;
  width: 130px;
  height: 100px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background:
    linear-gradient(45deg, #f4f4f5 25%, transparent 25%) -0px -0px / 16px 16px,
    linear-gradient(-45deg, #f4f4f5 25%, transparent 25%) -0px -0px / 16px 16px,
    linear-gradient(45deg, transparent 75%, #f4f4f5 75%) -0px -0px / 16px 16px,
    linear-gradient(-45deg, transparent 75%, #f4f4f5 75%) -0px -0px / 16px 16px,
    #fafafa;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
}

.overlay-image svg {
  width: 30px;
  height: 30px;
}

.overlay-shape {
  top: 470px;
  left: 90px;
  width: 160px;
  height: 90px;
  border: 2px solid var(--accent);
  background: rgba(229, 72, 77, 0.08);
  border-radius: 3px;
}

.overlay-obj.selected {
  outline: 1.5px solid var(--accent);
  outline-offset: 3px;
  z-index: 5;
}

/* Formas fechadas (retângulo/elipse) já têm sua própria borda, que segue o
   border-radius (círculo p.ex.) — o outline de seleção acima, por ser
   sempre "quadrado" com raio próprio, aparecia como um segundo contorno
   concêntrico. Os resize handles (.overlay-obj.selected .resize-handle)
   já indicam a seleção para esses tipos, então basta suprimir o outline. */
.overlay-obj-shape.selected {
  outline: none;
}

.resize-handle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--surface);
  border: 1.5px solid var(--accent);
  border-radius: 2px;
  z-index: 6;
}

.rh-nw { top: -8px; left: -8px; cursor: nwse-resize; }
.rh-n  { top: -8px; left: calc(50% - 4px); cursor: ns-resize; }
.rh-ne { top: -8px; right: -8px; cursor: nesw-resize; }
.rh-e  { top: calc(50% - 4px); right: -8px; cursor: ew-resize; }
.rh-se { bottom: -8px; right: -8px; cursor: nwse-resize; }
.rh-s  { bottom: -8px; left: calc(50% - 4px); cursor: ns-resize; }
.rh-sw { bottom: -8px; left: -8px; cursor: nesw-resize; }
.rh-w  { top: calc(50% - 4px); left: -8px; cursor: ew-resize; }

/* --- Painel de propriedades --- */

.props-panel {
  grid-area: props;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.props-panel.is-empty .props-body,
.props-panel.is-empty .props-header {
  display: none;
}

.props-empty-msg {
  display: none;
  padding: var(--sp-6) var(--sp-4);
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
}

.props-panel.is-empty .props-empty-msg {
  display: block;
}

.props-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border);
}

.props-header h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.props-body {
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.field textarea,
.field input[type="text"],
.field input[type="number"] {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color .15s ease, box-shadow .15s ease;
}

.field textarea:focus,
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.field textarea {
  resize: vertical;
  min-height: 64px;
}

.number-stepper {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  width: fit-content;
}

.number-stepper input {
  border: none !important;
  width: 56px;
  text-align: center;
  box-shadow: none !important;
  border-radius: 0 !important;
}

.stepper-btn {
  width: 28px;
  border: none;
  background: var(--bg-app);
  color: var(--text-secondary);
  font-size: 15px;
  cursor: pointer;
  line-height: 1;
}

.stepper-btn:hover {
  background: var(--border);
  color: var(--text-primary);
}

.swatches {
  display: flex;
  gap: 8px;
}

.swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
  padding: 0;
  position: relative;
}

.swatch.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--accent);
}

.style-toggles {
  display: flex;
  gap: 6px;
}

.toggle-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.toggle-btn.italic {
  font-style: italic;
}

.toggle-btn:hover {
  border-color: var(--accent);
}

.toggle-btn.active {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent);
}

.align-toggles {
  display: flex;
  gap: 6px;
}

.align-toggles .toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
}

.align-toggles .toggle-btn svg {
  width: 16px;
  height: 16px;
}

.prop-select {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.prop-select:hover {
  border-color: var(--accent);
}

.props-divider {
  height: 1px;
  background: var(--border);
  border: none;
  margin: 0;
}

.grid-2x2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}

.field-inline label {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.field-inline label span.field-tag {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-tertiary);
  background: var(--bg-app);
  padding: 1px 6px;
  border-radius: 4px;
}

.btn-block {
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   Modais
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--sp-4);
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#modal-signature .modal-card { max-width: 520px; }
#modal-insert-pdf .modal-card { max-width: 460px; }
#modal-images .modal-card { max-width: 560px; }
#modal-ocr .modal-card { max-width: 440px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-6);
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.modal-body {
  padding: var(--sp-6);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border);
}

.modal-footer .btn {
  padding: 9px 18px;
}

/* Assinatura */

.sig-tabs {
  display: flex;
  gap: var(--sp-1);
  background: var(--bg-app);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.sig-tab {
  flex: 1;
  padding: 8px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

.sig-tab.active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.sig-pane {
  display: none;
}

.sig-pane.active {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.sig-canvas {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-app);
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sig-canvas svg {
  width: 220px;
  height: 90px;
}

.sig-tools-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.link-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}

.link-btn:hover {
  color: var(--accent);
}

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

.sig-color-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}

.sig-color-dot.selected {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--accent);
}

.sig-type-input {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}

.sig-type-preview {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-app);
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Snell Roundhand', 'Brush Script MT', cursive;
  font-size: 34px;
  color: #1E293B;
}

.sig-upload-drop {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 28px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13.5px;
  cursor: pointer;
}

.sig-upload-drop:hover {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--accent);
}

.sig-upload-drop svg {
  width: 26px;
  height: 26px;
  margin: 0 auto 8px;
  color: var(--text-tertiary);
}

/* Assinatura — aba "Salvas" */

.sig-saved-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-3);
}

.sig-saved-card {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.sig-saved-card:hover {
  border-color: var(--accent);
}

.sig-saved-card.selected {
  border: 2px solid var(--accent);
  padding: 5px;
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.sig-saved-card img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.sig-saved-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transition: opacity .12s ease, color .15s ease, border-color .15s ease;
}

.sig-saved-card:hover .sig-saved-delete {
  opacity: 1;
}

.sig-saved-delete:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.sig-saved-delete svg {
  width: 11px;
  height: 11px;
}

.sig-saved-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
  padding: 32px 16px;
}

/* ==========================================================================
   Carimbo (js/carimbo.js) — reaproveita a maior parte das classes .sig-*
   (abas, grade "Salvas", cores) definidas acima; abaixo só o que é
   específico do carimbo (preview de texto multi-linha nos cards e no
   formulário de criação).
   ========================================================================== */

.carimbo-saved-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3);
}

.carimbo-saved-card {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.carimbo-saved-card:hover {
  border-color: var(--accent);
}

.carimbo-saved-card.selected {
  border: 2px solid var(--accent);
  padding: 7px;
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.carimbo-saved-card-text {
  width: 100%;
  white-space: pre-wrap;
  overflow: hidden;
  line-height: 1.25;
  word-wrap: break-word;
}

.carimbo-saved-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transition: opacity .12s ease, color .15s ease, border-color .15s ease;
}

.carimbo-saved-card:hover .carimbo-saved-delete {
  opacity: 1;
}

.carimbo-saved-delete:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.carimbo-saved-delete svg {
  width: 11px;
  height: 11px;
}

.carimbo-saved-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
  padding: 32px 16px;
}

.carimbo-preview {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-app);
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.carimbo-preview-text {
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.25;
  width: 100%;
}

.carimbo-field-row {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-end;
  flex-wrap: wrap;
}

.carimbo-textarea {
  width: 100%;
  min-height: 76px;
  resize: vertical;
  margin-top: var(--sp-3);
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text-primary);
}

.carimbo-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.carimbo-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin-top: var(--sp-3);
}

.carimbo-form-row {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  flex-wrap: wrap;
}

.carimbo-form-row .prop-select {
  width: auto;
  flex: 1;
  min-width: 140px;
}

/* Assinatura — modo trackpad (aba Desenhar) */

.sig-canvas-inner {
  position: relative;
  width: 460px;
  height: 160px;
}

.sig-canvas-inner canvas {
  position: relative;
  z-index: 1;
}

.sig-trackpad-dot {
  position: absolute;
  top: 0;
  left: 0;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--accent);
  pointer-events: none;
  z-index: 2;
}

.sig-trackpad-dot.pen-up {
  background: var(--surface);
}

.sig-trackpad-hint {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--accent-tint);
  border: 1px solid var(--accent-tint-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  text-align: center;
}

/* Assinatura — checkbox "Salvar para reutilizar" no rodapé do modal */

.sig-save-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  margin-right: auto;
}

.sig-save-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* Inserir PDF */

.small-dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13.5px;
  cursor: pointer;
  font-weight: 600;
}

.small-dropzone:hover {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--accent);
}

.small-dropzone svg {
  width: 24px;
  height: 24px;
  margin: 0 auto 8px;
  color: var(--text-tertiary);
}

.file-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.file-row .file-icon {
  width: 28px;
  height: 28px;
  color: var(--accent);
  flex-shrink: 0;
}

.file-row .file-info {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.file-row .file-info small {
  display: block;
  font-weight: 400;
  color: var(--text-secondary);
}

.radio-group-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
}

.radio-option:hover {
  border-color: var(--accent);
}

.radio-option input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

.radio-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Imagens -> PDF */

.image-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3);
}

.image-tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: linear-gradient(135deg, #E4E4E7, #F4F4F5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
}

.image-tile svg {
  width: 26px;
  height: 26px;
}

.image-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.image-tile .tile-remove {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(24,24,27,0.55);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.image-tile .tile-remove svg {
  width: 11px;
  height: 11px;
  color: #fff;
}

.image-tile .tile-drag {
  position: absolute;
  bottom: 5px;
  left: 5px;
  color: rgba(24,24,27,0.35);
}

.image-tile .tile-drag svg {
  width: 14px;
  height: 14px;
}

.image-tile .tile-order {
  position: absolute;
  bottom: 5px;
  left: 5px;
  display: flex;
  gap: 4px;
}

.image-tile .tile-order button {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(24,24,27,0.55);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.image-tile .tile-order button svg {
  width: 10px;
  height: 10px;
  color: #fff;
}

.image-tile .tile-order button:disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}

.image-tile-add {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  border: 2px dashed var(--border-strong);
  background: transparent;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.image-tile-add:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-tint);
}

.image-tile-add svg {
  width: 26px;
  height: 26px;
}

/* ==========================================================================
   Fase B — Núcleo funcional (js/render.js, js/utils.js, js/export.js)
   ========================================================================== */

/* --- Página renderizada no canvas central (js/render.js) --- */

.page-wrap {
  position: relative;
  flex-shrink: 0;
}

.page-inner {
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  border-radius: 2px;
  /* "visible" (não "hidden"): overlays que se estendem além da página devem
     continuar aparecendo por cima da margem cinza ao redor, em vez de serem
     cortados na borda — o retângulo branco da página em si continua nítido
     porque ele é desenhado exatamente do tamanho da página em .page-canvas,
     sem depender de clipping aqui. Isto afeta só a TELA de edição: na
     exportação (js/export.js, via pdf-lib) tudo que fica além do MediaBox da
     página é naturalmente cortado pelo próprio formato PDF — comportamento
     esperado e correto. */
  overflow: visible;
}

.page-canvas {
  display: block;
}

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

/* --- Miniaturas (sidebar) --- */

.thumb-canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 2px;
}

.page-thumb {
  padding: 0;
  align-items: center;
  justify-content: center;
}

.page-thumb.selected {
  padding: 0;
}

/* Arrastar miniatura para reordenar */

.thumb-dragging-source {
  opacity: 0.35;
}

.thumb-drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 300;
  pointer-events: none;
  opacity: 0.9;
  box-shadow: var(--shadow-lg);
  border-radius: 6px;
  transform: rotate(-2deg);
}

body.is-dragging-thumb {
  cursor: grabbing;
}

.thumb-drop-before,
.thumb-drop-after {
  position: relative;
}

.thumb-drop-before::before,
.thumb-drop-after::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
}

.thumb-drop-before::before {
  top: -8px;
}

.thumb-drop-after::after {
  bottom: -8px;
}

/* --- Botão "Baixar PDF" ocupado (js/export.js) --- */

.btn.is-busy {
  opacity: 0.6;
  pointer-events: none;
  cursor: default;
}

/* --- Toasts (js/utils.js) --- */

.toast-container {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 500;
  pointer-events: none;
}

.toast {
  background: var(--text-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .18s ease, transform .18s ease;
  max-width: 360px;
  text-align: center;
}

.toast-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-error {
  background: var(--accent-active);
}

/* ==========================================================================
   Overlays de objetos (js/overlay.js)
   Reaproveita .overlay-obj / .overlay-obj.selected / .resize-handle / .rh-*
   já definidos acima (mock); adiciona apenas o que falta para os tipos
   concretos e o painel de propriedades dinâmico.
   ========================================================================== */

.overlay-layer .overlay-obj {
  /* .overlay-obj já define position:absolute + cursor:move */
}

.overlay-obj .resize-handle,
.overlay-obj .endpoint-handle {
  display: none;
}

.overlay-obj.selected .resize-handle,
.overlay-obj.selected .endpoint-handle {
  display: block;
}

.overlay-obj-text {
  white-space: pre-wrap;
  overflow: hidden;
  word-wrap: break-word;
  font-family: Helvetica, Arial, sans-serif;
  padding: 0;
}

.overlay-obj-text[contenteditable="true"] {
  cursor: text;
  outline: 1.5px dashed var(--accent);
  outline-offset: 2px;
}

.overlay-obj-image img {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
  object-fit: fill;
}

/* --- Máscara de imagem/assinatura ("Mascarar com forma") --- */

.overlay-obj-image.has-mask .mask-clipper {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

/* Posição/tamanho reais (retângulo absoluto de overlay.mask.img*) são
   aplicados via JS em cada <img> (updateMaskImagesLive(), js/overlay.js) —
   aqui só o necessário para que esse posicionamento funcione. */
.mask-clipped-img,
.mask-ghost-img {
  position: absolute;
  object-fit: fill;
}

.overlay-obj-image.has-mask .mask-ghost-img {
  opacity: .35;
}

.overlay-obj-image.mask-editing {
  cursor: grab;
}

.overlay-obj-image.mask-editing.mask-panning {
  cursor: grabbing;
}

.overlay-obj-image.mask-editing .mask-edit-outline {
  position: absolute;
  inset: 0;
  border: 1.5px dashed var(--accent);
  pointer-events: none;
}

.mask-edit-toolbar {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 8px 10px;
  z-index: 20;
  cursor: default;
  white-space: nowrap;
}

.mask-edit-toolbar.flip-above {
  top: auto;
  bottom: calc(100% + 8px);
}

.mask-edit-toolbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mask-edit-toolbar input[type="range"] {
  width: 120px;
  accent-color: var(--accent);
}

.mask-edit-toolbar .btn {
  padding: 7px 14px;
  font-size: 13px;
}

/* Linha "L"/"A" — dimensões da máscara (não da imagem), editáveis, em pontos. */
.mask-size-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mask-size-field {
  display: flex;
  align-items: center;
  gap: 5px;
}

.mask-size-field .field-tag {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-tertiary);
  background: var(--bg-app);
  padding: 1px 6px;
  border-radius: 4px;
}

.mask-size-field input[type="number"] {
  width: 52px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 5px 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color .15s ease, box-shadow .15s ease;
}

.mask-size-field input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

@media (pointer: coarse) {
  .mask-size-field input[type="number"] {
    width: 60px;
    padding: 7px 6px;
  }
}

/* --- Painel de propriedades: grade de formas de máscara --- */

.mask-shape-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mask-shape-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
}

.mask-shape-btn svg {
  width: 20px;
  height: 20px;
}

.mask-shape-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.mask-shape-btn.active {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--accent);
}

.overlay-obj-shape {
  box-sizing: border-box;
}

.overlay-obj-line {
  pointer-events: none;
}

.overlay-obj-line svg {
  position: absolute;
  inset: 0;
  overflow: visible;
  pointer-events: none;
}

.overlay-obj-line svg .overlay-line-hit {
  pointer-events: auto;
  cursor: move;
}

.overlay-obj-line .endpoint-handle {
  pointer-events: auto;
}

.overlay-shape-draft {
  position: absolute;
  border: 1.5px dashed var(--accent);
  background: var(--accent-tint);
  pointer-events: none;
}

.endpoint-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  background: var(--surface);
  border: 1.5px solid var(--accent);
  border-radius: 50%;
  cursor: crosshair;
  z-index: 6;
}

/* --- Painel de propriedades: campos extras --- */

.field label.checkbox-field {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
}

.checkbox-field input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.field input[type="range"] {
  accent-color: var(--accent);
  width: 100%;
  padding: 0;
}

[data-prop-group].prop-hidden {
  display: none !important;
}

/* ==========================================================================
   Assinatura (js/signature.js)
   ========================================================================== */

@font-face {
  font-family: 'Dancing Script';
  src: url('../assets/fonts/DancingScript-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

.sig-canvas canvas {
  width: 100%;
  max-width: 460px;
  height: 160px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  touch-action: none;
  cursor: crosshair;
}

.sig-type-preview {
  font-family: 'Dancing Script', 'Snell Roundhand', 'Brush Script MT', cursive;
  font-size: 42px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 var(--sp-4);
}

.sig-upload-preview {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-app);
  min-height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-3);
}

.sig-upload-preview img {
  max-width: 100%;
  max-height: 150px;
  display: block;
}

/* ==========================================================================
   Editar conteúdo (js/pdf-engine.js + js/content-edit.js)
   ========================================================================== */

.content-edit-hitbox {
  position: absolute;
  box-sizing: border-box;
  border: 1.5px dashed var(--info-blue);
  border-radius: 2px;
  background: transparent;
  cursor: text;
  z-index: 4;
}

.content-edit-hitbox.is-image {
  cursor: pointer;
}

.content-edit-hitbox:hover,
.content-edit-hitbox.selected {
  background: var(--info-blue-tint);
}

.content-edit-hitbox:hover::after {
  content: "Clique para editar";
  position: absolute;
  top: -26px;
  left: 0;
  background: var(--text-primary);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  pointer-events: none;
}

.content-edit-hitbox.is-image:hover::after {
  content: "Clique para selecionar";
}

body.content-edit-busy .content-edit-hitbox {
  pointer-events: none;
  opacity: .55;
}

.content-edit-hintbar {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--text-primary);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  max-width: calc(100vw - 48px);
}

.content-edit-hintbar-close {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 999px;
  flex-shrink: 0;
}

.content-edit-hintbar-close:hover {
  background: rgba(255, 255, 255, 0.28);
}

.content-edit-hintbar-ocr {
  background: var(--accent);
  border: none;
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 999px;
  flex-shrink: 0;
  white-space: nowrap;
}

.content-edit-hintbar-ocr:hover {
  filter: brightness(1.08);
}

body.content-edit-busy .content-edit-hintbar-ocr {
  opacity: .55;
  pointer-events: none;
}

.content-edit-spinner {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  pointer-events: none;
}

.content-edit-spinner-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

.content-edit-spinner-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: content-edit-spin .7s linear infinite;
  flex-shrink: 0;
}

.content-edit-spinner-text {
  white-space: nowrap;
}

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

.props-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.4;
}

.field-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.order-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

/* ==========================================================================
   Toque / mobile (iPad/iPhone)
   - touch-action: sem isto, arrastar um objeto com o dedo faz o navegador
     rolar/zoomar a página em vez de mover o objeto. Seguro no desktop.
   - alvos maiores em telas de toque (@media pointer: coarse).
   - layout responsivo (<=820px): a página cabe na largura (escala adaptativa
     em js/render.js getScale), a barra de ferramentas rola na horizontal e
     os painéis de Páginas/Propriedades viram gavetas inferiores.
   Ver js/mobile.js (gaveta de Páginas + backdrop).
   ========================================================================== */

.overlay-obj,
.resize-handle,
.endpoint-handle,
.mask-edit-toolbar {
  touch-action: none;
}

@media (pointer: coarse) {
  .resize-handle { width: 16px; height: 16px; }
  .endpoint-handle { width: 18px; height: 18px; }
  .btn-icon { width: 40px; height: 40px; }
  .tool-btn { padding: 8px 12px; }
}

/* Elementos que só existem no modo mobile (ex.: botão "Páginas"). */
.mobile-only { display: none !important; }

/* Alça/chevron da folha de propriedades: só no modo mobile (ver media query). */
.props-grabber,
.props-expand-chevron { display: none; }

.mobile-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .35);
  z-index: 55;
  display: none;
}
.mobile-backdrop.show { display: block; }

@media (max-width: 820px) {
  .mobile-only { display: inline-flex !important; }

  #screen-editor {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* respeita a barra dinâmica do Safari no iOS */
  }

  .toolbar {
    padding: 0 8px;
    gap: 6px;
    flex-shrink: 0;
  }
  .doc-name { display: none; }
  .toolbar-left,
  .toolbar-right { gap: 4px; }

  /* As ferramentas viram um MENU SUSPENSO (grade), aberto pelo botão
     "Ferramentas" — em vez de rolar na horizontal, que era ruim no iPhone.
     Reutiliza os mesmos botões (e o wiring de js/editor.js); só muda o
     layout: fora do fluxo, escondido até .open. */
  .toolbar-center {
    position: fixed;
    left: 8px;
    right: 8px;
    top: 56px; /* reposicionado no open via js/mobile.js conforme a altura real da barra */
    display: none;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    max-height: 72vh;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 62;
  }
  .toolbar-center.open { display: grid; }
  .toolbar-center .tool-sep { display: none; }
  .toolbar-center .tool-btn { width: 100%; padding: 12px 6px; }
  .toolbar-center .tool-btn-wrap { width: 100%; }
  .toolbar-center .tool-btn-wrap > .tool-btn { width: 100%; }

  /* Sub-menus (Forma/Girar) precisam ficar ACIMA do menu de ferramentas. */
  .tool-dropdown { z-index: 70; }

  .canvas-area {
    flex: 1;
    padding: 16px 8px 12px;
    -webkit-overflow-scrolling: touch;
  }

  /* Painel "Páginas" -> gaveta inferior com tira horizontal de miniaturas. */
  .sidebar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    max-height: 62vh;
    border-right: none;
    border-top: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(100%);
    transition: transform .2s ease;
    z-index: 60;
  }
  .sidebar.open { transform: translateY(0); }
  .sidebar-pages {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4) var(--sp-4);
  }
  .page-thumb-wrap { flex-shrink: 0; width: 116px; }
  .add-page-btn { flex-shrink: 0; width: 116px; align-self: stretch; }

  /* Painel de Propriedades -> folha inferior que sobe ao selecionar um objeto
     (dirigido pela classe .is-empty já gerenciada por js/overlay.js). Sobe
     RECOLHIDA (só o cabeçalho — "peek"), deixando o objeto visível e livre
     para arrastar/redimensionar; toca-se no cabeçalho/alça para expandir as
     propriedades. Ver js/mobile.js (toggle .expanded) e a reinicialização do
     estado recolhido a cada nova seleção em js/overlay.js. */
  .props-panel {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    max-height: 82vh;
    border-left: none;
    border-top: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(100%);
    transition: transform .2s ease;
    z-index: 50;
  }
  .props-panel:not(.is-empty) { transform: translateY(0); }

  .props-grabber {
    display: block;
    width: 40px;
    height: 4px;
    background: var(--border-strong);
    border-radius: 2px;
    margin: 8px auto 2px;
    flex-shrink: 0;
  }

  .props-header { cursor: pointer; justify-content: flex-start; gap: 0; }
  .props-expand-chevron {
    display: block;
    width: 20px;
    height: 20px;
    color: var(--text-tertiary);
    margin-left: auto;
    margin-right: var(--sp-2);
    transition: transform .2s ease;
  }
  /* Recolhido (padrão): esconde as propriedades; chevron aponta p/ cima
     (= "toque para expandir"). Expandido: mostra e rola; chevron inverte. */
  .props-panel:not(.expanded) .props-body { display: none; }
  .props-panel.expanded .props-body { display: flex; overflow-y: auto; }
  .props-panel.expanded .props-expand-chevron { transform: rotate(180deg); }
}
