/* ============================
   WebPdf — styles.css
   Estilos completos: shell, dropzone, workspace, modos Files/Pages,
   overlays, responsivo, a11y.
============================ */

:root {
  --color-primary: #1e3a8a;
  --color-primary-soft: #3b82f6;
  --color-primary-bg: #eff6ff;
  --color-text: #0f172a;
  --color-muted: #64748b;
  --color-border: #e2e8f0;
  --color-bg: #f8fafc;
  --color-card: #ffffff;
  --color-danger: #b91c1c;
  --color-danger-soft: #fee2e2;
  --color-success: #15803d;
  --color-warning: #b45309;
  --color-warning-soft: #fef3c7;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 18px 40px rgba(15, 23, 42, 0.18);

  --thumb-w: 160px;
  --gap: 18px;

  --transition: 180ms cubic-bezier(.2,.7,.3,1);
}

*,
*::before,
*::after { box-sizing: border-box; }

/* HTML hidden attribute deve sempre prevalecer sobre display de classes */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  background: var(--color-primary);
  color: #fff;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  text-decoration: none;
  z-index: 1000;
}
.skip-link:focus { left: 8px; }

/* Header */
.site-header {
  background: #fff;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 24px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--color-primary);
  font-weight: 700;
  font-size: 1.1rem;
}
.brand__icon { width: 30px; height: 30px; }
.site-nav {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}
.site-nav a {
  color: var(--color-muted);
  text-decoration: none;
  padding: 6px 4px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--color-text); }
.site-nav a.is-active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* Hero */
.hero {
  padding: 48px 0 24px;
  text-align: center;
}
.hero__title {
  font-size: clamp(1.8rem, 3.4vw, 2.6rem);
  margin: 0 0 12px;
  color: var(--color-primary);
  letter-spacing: -0.01em;
}
.hero__subtitle {
  max-width: 680px;
  margin: 0 auto;
  color: var(--color-muted);
  font-size: 1.05rem;
}

/* Dropzone */
.dropzone {
  margin: 24px auto 48px;
  max-width: 920px;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  background: #fff;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
  padding: 36px 24px;
}
.dropzone__inner {
  text-align: center;
  pointer-events: auto;
}
.dropzone[data-state="hover"],
.dropzone[data-state="drag"] {
  border-color: var(--color-primary-soft);
  background: var(--color-primary-bg);
}
.dropzone[data-state="drag"] {
  transform: scale(1.01);
}
.dropzone__icon {
  color: var(--color-primary-soft);
  margin: 0 auto 8px;
}
.dropzone__title {
  margin: 8px 0 6px;
  font-size: 1.4rem;
  color: var(--color-text);
}
.dropzone__hint {
  margin: 0 0 18px;
  color: var(--color-muted);
}
.dropzone__limits {
  margin: 20px 0 0;
  color: var(--color-muted);
  font-size: 0.9rem;
}

/* Buttons */
.btn {
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--color-text);
  transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition);
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.btn:focus-visible {
  outline: 3px solid var(--color-primary-soft);
  outline-offset: 2px;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn:not(:disabled):active { transform: translateY(1px); }

.btn--primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn--primary:not(:disabled):hover {
  background: #18306d;
  border-color: #18306d;
}

.btn--ghost {
  background: #fff;
  border-color: var(--color-border);
  color: var(--color-text);
}
.btn--ghost:not(:disabled):hover {
  background: var(--color-bg);
  border-color: var(--color-muted);
}

.btn--danger-soft {
  color: var(--color-danger);
  border-color: var(--color-danger-soft);
}
.btn--danger-soft:not(:disabled):hover {
  background: var(--color-danger-soft);
}

.btn--icon {
  width: 36px;
  height: 36px;
  padding: 0;
  justify-content: center;
  border-radius: var(--radius-md);
  border-color: var(--color-border);
  background: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1;
}

/* Workspace */
.workspace {
  padding: 12px 24px 60px;
  max-width: 1480px;
  margin: 0 auto;
}

/* Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  background: #fff;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 65px;
  z-index: 20;
}
.toolbar__group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.toolbar__group--zoom {
  margin-left: 4px;
}
.toolbar__spacer { flex: 1 1 auto; }

.seg {
  border: 1px solid var(--color-border);
  background: #fff;
  color: var(--color-muted);
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  transition: background var(--transition), color var(--transition);
}
.seg:focus-visible {
  outline: 3px solid var(--color-primary-soft);
  outline-offset: 2px;
  z-index: 1;
  position: relative;
}
.seg--first {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}
.seg--last {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  border-left: 0;
}
.seg.is-active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.zoom-readout {
  min-width: 52px;
  text-align: center;
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}

.counters {
  margin: 14px 4px 0;
  color: var(--color-muted);
  font-size: 0.9rem;
}

/* Grids */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--thumb-w), 1fr));
  gap: var(--gap);
  margin-top: 20px;
}

/* Cards */
.card {
  --card-bg: #fff;
  background: var(--card-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition), opacity var(--transition);
  cursor: grab;
  user-select: none;
}
.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.card:focus-visible {
  outline: 3px solid var(--color-primary-soft);
  outline-offset: 2px;
}
.card[aria-grabbed="true"],
.card.is-dragging {
  opacity: 0.4;
  transform: scale(0.98);
  cursor: grabbing;
}
.card.is-drop-target-before::before,
.card.is-drop-target-after::after {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--color-primary);
  border-radius: 3px;
  z-index: 5;
}
.card.is-drop-target-before::before { left: -10px; }
.card.is-drop-target-after::after { right: -10px; }

.card__thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 0.72;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.card__img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform var(--transition);
}
.card__skeleton {
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, #e2e8f0 8%, #f1f5f9 18%, #e2e8f0 33%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.card__badge {
  position: absolute;
  background: rgba(15,23,42,0.78);
  color: #fff;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
}
.card__badge--count {
  top: 8px;
  right: 8px;
}

.card__meta {
  padding: 8px 10px 12px;
}
.card__meta--page {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
}
.card__title {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card__sub {
  margin: 4px 0 0;
  font-size: 0.78rem;
  color: var(--color-muted);
}
.card__page-num {
  font-weight: 600;
  color: var(--color-text);
}
.card__file-ref {
  color: var(--color-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
  text-align: right;
}

.card__actions {
  position: absolute;
  top: 6px;
  left: 6px;
  right: 6px;
  display: flex;
  justify-content: space-between;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}
.card:hover .card__actions,
.card:focus-within .card__actions {
  opacity: 1;
  pointer-events: auto;
}

.card__btn {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(15,23,42,0.78);
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  line-height: 1;
  transition: background var(--transition), transform var(--transition);
}
.card__btn:hover { background: var(--color-primary); }
.card__btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}
.card__btn--remove:hover { background: var(--color-danger); }
.card__btn--move-left,
.card__btn--move-right,
.card__btn--rotate { background: rgba(15,23,42,0.55); }

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  backdrop-filter: blur(2px);
}
.overlay__card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 460px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.overlay__title {
  margin: 0 0 8px;
  font-size: 1.3rem;
  color: var(--color-text);
}
.overlay__message {
  margin: 0 0 18px;
  color: var(--color-muted);
}
.overlay__detail {
  margin: 12px 0 0;
  color: var(--color-muted);
  font-size: 0.85rem;
  min-height: 1.4em;
}
.overlay__actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
  flex-wrap: wrap;
}
.overlay__check {
  margin: 0 auto 14px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #d1fae5;
  color: var(--color-success);
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}
.progress__bar {
  height: 100%;
  background: var(--color-primary);
  width: 0%;
  transition: width 200ms ease-out;
}

/* Forms (resultado) */
.field-label {
  display: block;
  text-align: left;
  margin: 14px 0 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-muted);
}
.field-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.field {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
  color: var(--color-text);
}
.field:focus-visible {
  outline: 3px solid var(--color-primary-soft);
  outline-offset: 2px;
  border-color: var(--color-primary-soft);
}

/* Toasts */
.toast-host {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
  max-width: calc(100vw - 48px);
  pointer-events: none;
}
.toast {
  background: var(--color-text);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 0.9rem;
  pointer-events: auto;
  max-width: 380px;
  animation: toast-in 240ms cubic-bezier(.2,.7,.3,1);
  display: flex;
  align-items: center;
  gap: 12px;
}
.toast__action {
  background: transparent;
  color: #93c5fd;
  border: 0;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 4px 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: inherit;
}
.toast__action:hover { color: #fff; }
.toast__action:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}
.toast--error { background: var(--color-danger); }
.toast--warning { background: var(--color-warning); }
.toast--success { background: var(--color-success); }
@keyframes toast-in {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Footer */
.site-footer {
  background: #fff;
  border-top: 1px solid var(--color-border);
  padding: 28px 0;
  margin-top: 24px;
}
.site-footer__inner {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  text-align: center;
  font-size: 0.88rem;
  color: var(--color-muted);
}
.site-footer__brand a {
  color: var(--color-primary);
  text-decoration: none;
}
.site-footer__notice {
  color: var(--color-muted);
  margin: 4px 0;
}
.site-footer__notice strong { color: var(--color-text); }
.site-footer__links {
  list-style: none;
  display: flex;
  gap: 18px;
  padding: 0;
  margin: 4px 0 0;
  flex-wrap: wrap;
  justify-content: center;
}
.site-footer__links a {
  color: var(--color-muted);
  text-decoration: none;
}
.site-footer__links a:hover { color: var(--color-primary); }

/* Prose pages (about / privacy) */
.prose {
  padding: 48px 0 64px;
  max-width: 760px;
}
.prose h1 {
  font-size: 2rem;
  color: var(--color-primary);
  margin: 0 0 12px;
}
.prose h2 {
  font-size: 1.25rem;
  margin: 28px 0 10px;
}
.prose .lead {
  font-size: 1.1rem;
  color: var(--color-muted);
  margin: 0 0 24px;
}
.prose p { margin: 10px 0; }
.prose ul { padding-left: 22px; }
.prose__updated {
  margin-top: 36px;
  font-size: 0.85rem;
  color: var(--color-muted);
  font-style: italic;
}
.limits-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 18px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.limits-table th,
.limits-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}
.limits-table thead th {
  background: var(--color-bg);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.limits-table tbody tr:last-child td { border-bottom: 0; }

/* Landing — cards de ferramentas */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
  max-width: 860px;
  margin: 8px auto 56px;
}
.tool-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 28px 24px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--color-text);
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
}
.tool-card:hover,
.tool-card:focus-visible {
  border-color: var(--color-primary-soft);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.tool-card__icon {
  color: var(--color-primary);
  background: var(--color-primary-bg);
  width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}
.tool-card__title {
  margin: 0;
  font-size: 1.2rem;
  color: var(--color-primary);
}
.tool-card__badge {
  display: inline-block;
  vertical-align: middle;
  margin-left: 6px;
  padding: 2px 8px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-success);
  background: #dcfce7;
  border-radius: 999px;
}
.tool-card__desc {
  margin: 0;
  color: var(--color-muted);
  font-size: 0.95rem;
  flex: 1;
}
.tool-card__cta {
  color: var(--color-primary-soft);
  font-weight: 600;
  font-size: 0.92rem;
}

/* ============================================================
   Editar PDF
   ============================================================ */

.hero__note {
  margin: 10px auto 0;
  max-width: 640px;
  font-size: 0.85rem;
  color: var(--color-warning);
}

/* Modo edição: header/footer institucionais saem da tela (links continuam
   na landing e na tela de upload). Classe controlada por edit-app.js. */
body.edit-active .site-header,
body.edit-active .site-footer {
  display: none;
}

.edit-workspace {
  display: flex;
  flex-direction: column;
  /* só visível em body.edit-active (header/footer ocultos) */
  height: 100vh;
  min-height: 480px;
  --tools-w: 208px;
  --thumbs-w: 190px;
}
.edit-workspace[data-tools-collapsed="true"] { --tools-w: 56px; }
.edit-workspace[data-thumbs-collapsed="true"] { --thumbs-w: 44px; }

/* Barra superior: nome do arquivo + ações */
.editbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
}
.editbar__brand {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--color-primary);
  font-weight: 700;
  text-decoration: none;
  flex-shrink: 0;
  padding-right: 8px;
  border-right: 1px solid var(--color-border);
}
.editbar__brand:hover { opacity: 0.75; }
.filename-edit {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
#edit-filename-display {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
#edit-filename-input {
  max-width: 340px;
  padding: 6px 10px;
}
.editbar__actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.btn--danger {
  background: var(--color-danger);
  border-color: var(--color-danger);
}
.btn--danger:hover { filter: brightness(1.1); }

/* Sidebar esquerda de ferramentas (vertical, recolhível).
   Mantém a classe .edit-toolbar — o seletor de edit-app.js depende dela. */
.edit-toolbar.edit-tools {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: var(--tools-w, 208px);
  flex-shrink: 0;
  padding: 8px 6px;
  background: var(--color-card);
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  overflow-x: hidden;
  transition: width var(--transition);
}
.edit-tools__toggle { align-self: flex-start; margin-bottom: 2px; }
.edit-workspace[data-tools-collapsed="true"] .edit-tools__toggle { align-self: center; }

.edit-tools .toolbar__group {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}
.edit-tools .seg {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  justify-content: flex-start;
  padding: 9px 10px;
  white-space: nowrap;
}
.edit-tools .seg--first,
.edit-tools .seg--last {
  border-radius: var(--radius-sm);
  border-left: 1px solid transparent;
}
.edit-tools .seg:hover { background: var(--color-primary-bg); color: var(--color-primary); }
.edit-tools .seg.is-active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.edit-tools .seg svg { flex-shrink: 0; }
.edit-tools__undo {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-start;
  margin-top: 8px;
  white-space: nowrap;
  width: 100%;
  height: auto;
  padding: 9px 10px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-sm);
}
.edit-tools__undo:hover:not(:disabled) { background: var(--color-primary-bg); }
.edit-workspace[data-tools-collapsed="true"] .edit-tools__undo { width: auto; align-self: center; }
.edit-tools__undo .seg__label { font-size: 0.9rem; font-weight: 600; }
.edit-workspace[data-tools-collapsed="true"] .seg__label { display: none; }
.edit-workspace[data-tools-collapsed="true"] .edit-tools .seg,
.edit-workspace[data-tools-collapsed="true"] .edit-tools__undo {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

/* Corpo: sidebar de miniaturas + palco central */
.edit-body {
  display: flex;
  flex: 1;
  min-height: 0; /* permite os filhos rolarem */
}
/* Sidebar direita de miniaturas (recolhível) */
.edit-sidebar {
  width: var(--thumbs-w, 190px);
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--color-card);
  border-left: 1px solid var(--color-border);
  padding: 8px;
  transition: width var(--transition);
}
.edit-sidebar__toggle { display: block; margin: 0 auto 8px; }
.edit-workspace[data-thumbs-collapsed="true"] .edit-sidebar { padding: 8px 4px; }
.edit-workspace[data-thumbs-collapsed="true"] .edit-sidebar__counter,
.edit-workspace[data-thumbs-collapsed="true"] .thumb-list { display: none; }
.edit-sidebar__counter {
  margin: 0 0 10px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
}
.thumb-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.thumb-item {
  display: block;
  width: 100%;
  padding: 5px;
  background: none;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.thumb-item:hover { border-color: var(--color-border); }
.thumb-item.is-active {
  border-color: var(--color-primary-soft);
  background: var(--color-primary-bg);
}
.thumb-item__frame {
  display: block;
  position: relative;
  background: #fff;
  border: 1px solid var(--color-border);
  overflow: hidden;
}
.thumb-item__frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.thumb-item__skeleton {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, #eef2f7 40%, #f8fafc 50%, #eef2f7 60%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
}
@keyframes shimmer {
  to { background-position: -200% 0; }
}
.thumb-item__num {
  display: block;
  margin-top: 4px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--color-muted);
}
/* Miniatura que falhou: sinaliza sem bloquear a edição da página */
.thumb-item--error .thumb-item__frame {
  border-color: var(--color-danger);
  background: #fff6f6;
}
.thumb-item__error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-danger);
}

.edit-stage-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
}
.edit-stage {
  flex: 1;
  overflow: auto;
  background: #e8edf3;
  padding: 24px;
}
/* Zoom flutuante sobre o stage (não ocupa linha própria) */
.stage-zoom {
  position: absolute;
  top: 10px;
  right: 16px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px 4px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.page-wrap {
  position: relative;
  margin: 0 auto;
  background: #fff;
  box-shadow: var(--shadow-md);
}
#page-canvas { display: block; }
/* Falha de UMA página: aviso sobre a página, sem derrubar o documento */
.page-error {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 24px);
  padding: 8px 12px;
  background: var(--color-danger-soft);
  border: 1px solid var(--color-danger);
  border-radius: var(--radius-md);
  color: var(--color-danger);
  font-size: 0.86rem;
  box-shadow: var(--shadow-sm);
}
.page-error__btn {
  flex: none;
  padding: 4px 10px;
  background: #fff;
  border: 1px solid var(--color-danger);
  border-radius: var(--radius-sm);
  color: var(--color-danger);
  font: inherit;
  cursor: pointer;
}
.page-error__btn:hover { background: var(--color-danger); color: #fff; }
.overlay-layer {
  position: absolute;
  inset: 0;
}

/* Elementos sobrepostos */
.el {
  position: absolute;
  box-sizing: border-box;
  touch-action: none;
  user-select: none;
  cursor: move;
  /* outline (não border): não desloca o conteúdo nem encolhe os SVGs
     internos — o retângulo do elemento fica fiel ao export */
  outline: 1px dashed transparent;
  outline-offset: 0;
}
.el:hover { outline-color: rgba(59, 130, 246, 0.55); }
.el.is-selected { outline: 1px solid var(--color-primary-soft); }
.el__content {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  overflow: hidden;
}
.el--text .el__content {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
}
.el--text .el__content[contenteditable] {
  cursor: text;
  user-select: text;
  outline: none;
}
.el--text .el__content:empty::before {
  content: attr(data-placeholder);
  color: #9ca3af;
}
.el--image .el__content img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.el__handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #fff;
  border: 1.5px solid var(--color-primary-soft);
  border-radius: 2px;
  display: none;
  z-index: 2;
}
.el.is-selected .el__handle { display: block; }
.el__handle[data-h="nw"] { top: -5px; left: -5px; cursor: nwse-resize; }
.el__handle[data-h="n"]  { top: -5px; left: calc(50% - 5px); cursor: ns-resize; }
.el__handle[data-h="ne"] { top: -5px; right: -5px; cursor: nesw-resize; }
.el__handle[data-h="e"]  { top: calc(50% - 5px); right: -5px; cursor: ew-resize; }
.el__handle[data-h="se"] { bottom: -5px; right: -5px; cursor: nwse-resize; }
.el__handle[data-h="s"]  { bottom: -5px; left: calc(50% - 5px); cursor: ns-resize; }
.el__handle[data-h="sw"] { bottom: -5px; left: -5px; cursor: nesw-resize; }
.el__handle[data-h="w"]  { top: calc(50% - 5px); left: -5px; cursor: ew-resize; }
/* Imagem: proporção travada — só alças de canto */
.el--image .el__handle[data-h="n"],
.el--image .el__handle[data-h="s"],
.el--image .el__handle[data-h="e"],
.el--image .el__handle[data-h="w"] { display: none; }

/* Lixeira on-box removida (2026-07-08): exclusão agora é só pelo menu
   flutuante (#fmt-delete no texto, botão da props-bar nos demais) + Delete. */

/* Barra flutuante de formatação */
.format-bar {
  position: fixed;
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}
.format-bar__select {
  padding: 4px 6px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 0.85rem;
}
.format-bar__select--size { width: 58px; }
.format-bar__btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
}
.format-bar__btn--bold { font-weight: 700; }
.format-bar__btn--italic { font-style: italic; }
.format-bar__btn.is-active {
  background: var(--color-primary-bg);
  border-color: var(--color-primary-soft);
  color: var(--color-primary);
}
.format-bar__btn--danger { color: var(--color-danger); }
.format-bar__btn--danger:hover {
  background: var(--color-danger-soft);
  border-color: var(--color-danger);
}
.format-bar__swatches {
  display: flex;
  gap: 4px;
  align-items: center;
}
.format-bar__swatch {
  width: 18px;
  height: 18px;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
}
.format-bar__swatch:hover { transform: scale(1.15); }
/* Controle de cor próprio (color-control.js) — substitui <input type=color>
   nativo (cujo conta-gotas trava a aba dentro do iframe do SaaS). */
/* Slot do controle na barra de texto: inline-flex evita gap de baseline
   (span inline embrulhando inline-flex ficava 34px e a barra crescia). */
#fmt-color-slot { display: inline-flex; align-items: center; }
.color-control { position: relative; display: inline-flex; }
.color-control__trigger {
  width: 30px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #000;
  cursor: pointer;
}
.color-control__trigger:hover { border-color: var(--color-primary); }
.color-control__popover {
  position: fixed;
  z-index: 170;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}
.color-control__swatches {
  display: grid;
  grid-template-columns: repeat(6, 18px);
  gap: 6px;
}
.color-control__row { display: flex; align-items: center; gap: 6px; }
.color-control__hex {
  width: 82px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  padding: 4px 6px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}
.color-control__eyedrop {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-card);
  color: var(--color-text);
  cursor: pointer;
}
.color-control__eyedrop:hover {
  background: var(--color-bg);
  border-color: var(--color-primary);
}

/* Highlight / Shapes / Draw / Eraser
   ⚠ NÃO adicionar transform/z-index/isolation em .overlay-layer ou
   .page-wrap — criaria stacking context e isolaria o mix-blend-mode do
   highlight do canvas da página. */
.el--highlight .el__content {
  mix-blend-mode: multiply; /* paridade com BlendMode.Multiply no PDF */
}
.el--circle .el__content { border-radius: 50%; }
.el--rect .el__content,
.el--circle .el__content { box-sizing: border-box; }
/* Círculo: proporção travada — só alças de canto (como imagem) */
.el--circle .el__handle[data-h="n"],
.el--circle .el__handle[data-h="s"],
.el--circle .el__handle[data-h="e"],
.el--circle .el__handle[data-h="w"] { display: none; }

.el__svg,
.el__content svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

/* Seta/Linha: sem alças de caixa; só endpoints */
.el--arrow .el__handle:not(.el__handle--endpoint),
.el--line .el__handle:not(.el__handle--endpoint) { display: none !important; }
.el__handle--endpoint {
  border-radius: 50%;
  width: 12px;
  height: 12px;
  cursor: crosshair;
}
.el--arrow.is-selected .el__handle--endpoint,
.el--line.is-selected .el__handle--endpoint { display: block; }

/* Stroke: mover/excluir apenas */
.el--stroke .el__handle { display: none !important; }

/* Overlay em modo ferramenta: elementos não interceptam o ponteiro;
   toque não rola a página (desenho com o dedo/stylus) */
.overlay-layer--tool { touch-action: none; cursor: crosshair; }
.overlay-layer--tool .el { pointer-events: none; }
.overlay-layer--eraser { cursor: none; }

/* Modo colagem: cursor de cópia + aviso flutuante */
body.paste-active #overlay-layer,
body.paste-active #overlay-layer .el,
body.paste-active #overlay-layer .el * { cursor: copy !important; }

/* Modo conta-gotas: cursor de mira sobre a página */
body.eyedrop-active #overlay-layer,
body.eyedrop-active #overlay-layer .el,
body.eyedrop-active #overlay-layer .el *,
body.eyedrop-active #page-canvas { cursor: crosshair !important; }
.paste-hint {
  position: fixed;
  z-index: 160;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 8px 16px;
  background: var(--color-primary);
  color: #fff;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  font-weight: 600;
  pointer-events: none;
  white-space: nowrap;
}
.paste-hint__esc { opacity: 0.8; font-weight: 400; }

.eraser-cursor {
  position: fixed;
  z-index: 140;
  border: 1.5px solid #334155;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.18);
  pointer-events: none;
}

/* Preview do traço durante o gesto (fora do sistema .el) */
.draw-preview {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

/* Painel da ferramenta ativa (Draw/Eraser) — flutuante sobre o stage,
   não empurra o canvas (ticket layout §13) */
.tool-panel {
  position: absolute;
  top: 10px;
  left: 16px;
  z-index: 25;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  max-width: calc(100% - 190px);
  padding: 8px 12px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.props-bar { flex-wrap: wrap; max-width: min(92vw, 560px); }
.props__label {
  font-size: 0.78rem;
  color: var(--color-muted);
  white-space: nowrap;
}
.props__range { width: 80px; accent-color: var(--color-primary-soft); }
.props__check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
}
.props__check input { accent-color: var(--color-primary-soft); }

/* Menu "usar última imagem" */
.image-reuse-menu {
  position: fixed;
  z-index: 150;
  display: flex;
  flex-direction: column;
  min-width: 180px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.image-reuse-menu__btn {
  padding: 10px 14px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font-size: 0.92rem;
}
.image-reuse-menu__btn:hover { background: var(--color-primary-bg); }

/* Responsivo */
@media (max-width: 720px) {
  .site-header__inner { padding: 12px 16px; flex-wrap: wrap; }
  .site-nav { gap: 14px; font-size: 0.92rem; }
  .container { padding: 0 16px; }
  .hero { padding: 28px 0 12px; }
  .hero__subtitle { font-size: 0.98rem; }
  .dropzone { margin: 16px auto 28px; padding: 24px 16px; }
  .workspace { padding: 6px 12px 40px; }
  .toolbar {
    padding: 10px;
    top: 60px;
  }
  .toolbar__spacer { width: 100%; height: 0; }
  :root { --thumb-w: 124px; --gap: 12px; }
  .tools-grid { grid-template-columns: 1fr; }
  .edit-workspace { --tools-w: 180px; --thumbs-w: 140px; }
  .edit-workspace[data-tools-collapsed="true"] { --tools-w: 52px; }
  .edit-workspace[data-thumbs-collapsed="true"] { --thumbs-w: 40px; }
  .edit-stage { padding: 12px; }
  .editbar { flex-wrap: wrap; }
  .editbar__brand-text { display: none; }
  .card__actions { opacity: 1; pointer-events: auto; } /* sempre visível em touch */
  .toast-host { right: 12px; left: 12px; bottom: 12px; }
  .toast { max-width: none; }
}

@media (max-width: 420px) {
  .seg { padding: 6px 10px; font-size: 0.85rem; }
  .btn { padding: 8px 12px; font-size: 0.88rem; }
  .brand__text { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-color-scheme: dark) {
  /* Mantém claro por padrão; ajuste futuro caso desejado */
}

/* ==========================================================================
   PDFs Favoritos (estrela nas ferramentas + seção na landing)
   ========================================================================== */

.fav-star { position: relative; }
.fav-star[data-state="disabled"] { opacity: 0.45; cursor: not-allowed; }
.fav-star[data-state="empty"] .fav-star__path { fill: none; stroke: var(--text-muted, #64748b); }
.fav-star[data-state="active"] .fav-star__path,
.fav-star[data-state="dirty"] .fav-star__path { fill: #f5b301; stroke: #d99a00; }
.fav-star[data-state="error"] .fav-star__path { fill: none; stroke: #dc2626; }
.fav-star[data-state="saving"] .fav-star__path {
  fill: none;
  stroke: var(--text-muted, #64748b);
  animation: fav-pulse 900ms ease-in-out infinite;
}
.fav-star[data-state="dirty"]::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #dc2626;
}
@keyframes fav-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.fav-badge {
  font-size: 0.8rem;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}

/* ---- Landing: seção Meus PDFs favoritos ---- */

.fav-section { margin-top: 40px; padding-bottom: 24px; }
.fav-section__title { font-size: 1.35rem; margin: 0 0 12px; }
.fav-status { color: var(--text-muted, #64748b); margin: 8px 0 0; }
.fav-invite { color: var(--text-muted, #64748b); margin: 8px 0 0; }
.fav-invite a { font-weight: 600; }

.fav-group { margin-top: 20px; }
.fav-group__title {
  font-size: 1rem;
  color: var(--text-muted, #64748b);
  margin: 0 0 10px;
  font-weight: 600;
}

.fav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.fav-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}
.fav-card__thumb {
  position: relative;
  height: 150px;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border, #e2e8f0);
}
.fav-card__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}
.fav-card__ph {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #94a3b8;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.fav-card__meta { padding: 10px 12px 4px; }
.fav-card__name {
  margin: 0 0 2px;
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fav-card__sub {
  margin: 0 0 4px;
  font-size: 0.82rem;
  color: var(--text-muted, #64748b);
}
.fav-card__dates {
  margin: 0;
  font-size: 0.75rem;
  color: #94a3b8;
  line-height: 1.4;
}
.fav-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px 12px;
  margin-top: auto;
}
.fav-card__actions .btn { padding: 6px 10px; font-size: 0.82rem; }

.fav-storage {
  margin: 18px 0 0;
  font-size: 0.8rem;
  color: #94a3b8;
}

/* ---- Modais dos favoritos ---- */

.fav-modal__error { color: #dc2626; font-size: 0.85rem; margin: 6px 0 0; }
.overlay__actions--stack { flex-wrap: wrap; }

@media (max-width: 719px) {
  .fav-badge { display: none; }
  .fav-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
