  :root {
    --bg: #0b0d12;
    --bg-soft: #0f131b;
    --card: #131926;
    --text: #e6e9ef;
    --muted: #a6adc8;
    --primary: #3b82f6; /* azul */
    --primary-contrast: #ffffff;
    --ring: #3b82f6;
  }

  :root[data-theme="light"] {
    --bg: #f6f8fc;
    --bg-soft: #ffffff;
    --card: #ffffff;
    --text: #0b1220;
    --muted: #425066;
    --primary: #3b82f6;
    --primary-contrast: #ffffff;
    --ring: #2563eb;
  }

  * { box-sizing: border-box; }
  html, body { height: 100%; }
  body {
    margin: 0;
    background:
      radial-gradient(1200px 600px at 10% -10%, rgba(59,130,246,.16), transparent 60%),
      radial-gradient(900px 400px at 90% 110%, rgba(59,130,246,.08), transparent 60%),
      var(--bg);
    color: var(--text);
    font: 500 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
  }

  .container { width: min(1100px, 94vw); margin: 0 auto; }

  /* Header + nav/drawer */
  .site-header { position: sticky; top: 0; z-index: 30; backdrop-filter: saturate(140%) blur(8px); background: color-mix(in oklab, var(--bg-soft) 88%, transparent); border-bottom: 1px solid color-mix(in oklab, var(--muted) 24%, transparent); }
  .header-inner { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; }
  .brand { display: inline-flex; gap: 10px; align-items: center; text-decoration: none; font-weight: 800; letter-spacing: .2px; color: var(--text); font-size: 20px; }
  .brand span { position: relative; top: 1px; }
  .brand-logo {
    width: 60px;      /* ajuste aqui se quiser maior/menor */
    height: 60px;
    display: block;
    object-fit: contain;
  }
  .header-actions { display: flex; gap: 10px; align-items: center; }
  .burger { width: 38px; height: 38px; border-radius: 10px; border: 1px solid color-mix(in oklab, var(--muted) 26%, transparent); background: var(--bg-soft); color: var(--text); cursor: pointer; }
  .lang { border-radius: 10px; padding: 8px 10px; border: 1px solid color-mix(in oklab, var(--muted) 26%, transparent); background: var(--bg-soft); color: var(--text); }

  .drawer { position: fixed; inset: 0 0 0 auto; width: min(320px, 86vw); transform: translateX(100%); transition: transform .18s ease; background: var(--bg-soft); border-left: 1px solid color-mix(in oklab, var(--muted) 24%, transparent); z-index: 50; display: grid; grid-template-rows: auto 1fr; }
  .drawer.open { transform: translateX(0); }
  .drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 14px; border-bottom: 1px solid color-mix(in oklab, var(--muted) 20%, transparent); }
  .drawer-list {
  /* mantêm as suas regras existentes */
  padding: 10px;
  display: grid;
  gap: 6px;

  /* adiciona estas linhas: */
  overflow: auto;                      /* <- faz a lista rolar */
  -webkit-overflow-scrolling: touch;   /* momentum scroll no iOS */
  overscroll-behavior: contain;        /* evita puxar o body */
  touch-action: pan-y;                 /* gestos de rolagem vertical */
}
  .drawer a { color: var(--text); text-decoration: none; padding: 10px 12px; border-radius: 10px; display: block; border: 1px solid color-mix(in oklab, var(--muted) 18%, transparent); background: var(--card); }
  .drawer a:hover { border-color: color-mix(in oklab, var(--ring) 30%, transparent); }
  .drawer-backdrop { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.35); backdrop-filter: blur(1px); opacity: 0; pointer-events: none; transition: opacity .18s ease; z-index: 40; }
  .drawer.open + .drawer-backdrop { opacity: 1; pointer-events: auto; }
#ext-links-group { padding-left: 12px; }  
  .hero { padding: 36px 0 14px; }
  .hero h1 { margin: 0 0 8px; font-size: clamp(24px, 3vw + 12px, 38px); letter-spacing: .3px; }
  .hero p { margin: 0; color: var(--muted); }

  .searchbar { margin-top: 18px; }
  .searchbar input { width: 100%; padding: 14px 16px; border-radius: 14px; border: 1px solid color-mix(in oklab, var(--muted) 26%, transparent); background: var(--bg-soft); color: var(--text); outline: none; }
  .searchbar input:focus { box-shadow: 0 0 0 4px color-mix(in oklab, var(--ring) 22%, transparent); border-color: var(--ring); }

  .tools-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; padding: 18px 0 36px; }
  @media (max-width: 980px) { .tools-grid { grid-template-columns: repeat(2, 1fr); } }
  @media (max-width: 640px) { .tools-grid { grid-template-columns: 1fr; } }

  /* cards clicáveis */
  .tool-card { background: linear-gradient(180deg, color-mix(in oklab, var(--card) 92%, transparent), var(--card)); border: 1px solid color-mix(in oklab, var(--muted) 20%, transparent); border-radius: 16px; padding: 18px; display: grid; gap: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.15); transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; text-decoration: none; color: inherit; cursor: pointer; }
  .tool-card:hover { transform: translateY(-1px); box-shadow: 0 16px 36px rgba(0,0,0,.2); border-color: color-mix(in oklab, var(--ring) 30%, transparent); }
  .tool-card h3 { margin: 0; font-size: 18px; }
  .tool-card p { margin: 0; color: var(--muted); min-height: 40px; }
  .tool-card.disabled { opacity: .6; cursor: not-allowed; pointer-events: none; }

  .site-footer { padding: 24px 0 36px; color: var(--muted); text-align: center; }

  /* Botões e formulários */
  /* === Ad slots (neutros, responsivos) === */
.ad-slot {
  display: grid;
  place-items: center;
  width: 100%;
  margin: 16px 0;
  min-height: 90px; /* evita CLS */
  border-radius: 12px;
  background: color-mix(in oklab, var(--card) 92%, transparent);
  border: 1px dashed color-mix(in oklab, var(--muted) 20%, transparent);
}
.ad-slot .adsbygoogle { width: 100%; }

@media (max-width: 640px) {
  .ad-slot { min-height: 60px; }
}

/* quando anúncios desativados, mostramos um placeholder discreto (local) */
.ad-placeholder {
  color: var(--muted);
  font-size: 13px;
  padding: 10px 12px;
}

  .btn { appearance: none; border: 1px solid color-mix(in oklab, var(--muted) 26%, transparent); background: var(--bg-soft); color: var(--text); padding: 10px 14px; border-radius: 12px; font-weight: 700; line-height: 1; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
  .btn:hover { border-color: color-mix(in oklab, var(--ring) 36%, transparent); }
  .btn.primary { background: linear-gradient(180deg, color-mix(in oklab, var(--primary) 88%, transparent), var(--primary)); color: var(--primary-contrast); border-color: transparent; }
  .btn.primary:hover { filter: saturate(1.08) brightness(1.02); }
  .btn.ghost { background: transparent; }

  /* páginas de ferramentas — grande, centralizado, card */
  .tool-page { width: min(880px, 96vw); margin: 56px auto; background: linear-gradient(180deg, color-mix(in oklab, var(--card) 94%, transparent), var(--card)); border: 1px solid color-mix(in oklab, var(--muted) 22%, transparent); border-radius: 20px; padding: 26px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
  .tool-page h1 { margin-top: 6px; font-size: clamp(22px, 2.2vw + 12px, 32px); }
  .muted { color: var(--muted); }
  .form-row { display: grid; gap: 12px; margin: 12px 0; }
  label { color: var(--muted); font-weight: 600; }
  input[type="file"], input[type="text"], input[type="password"], input[type="number"], select { width: 100%; background: var(--bg-soft); color: var(--text); border: 1px solid color-mix(in oklab, var(--muted) 26%, transparent); border-radius: 12px; padding: 12px 12px; outline: none; }
  input:focus, select:focus { box-shadow: 0 0 0 4px color-mix(in oklab, var(--ring) 22%, transparent); border-color: var(--ring); }
  .actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

  /* lista de arquivos com botão de remover */
  .file-picker { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
  .file-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
  .file-item { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; background: var(--bg-soft); border: 1px solid color-mix(in oklab, var(--muted) 18%, transparent); border-radius: 12px; padding: 10px 12px; }
  .file-item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .file-item .size { color: var(--muted); font-variant-numeric: tabular-nums; }
  .file-remove { border: 1px solid color-mix(in oklab, var(--muted) 26%, transparent); background: transparent; color: var(--text); width: 28px; height: 28px; border-radius: 999px; cursor: pointer; font-weight: 900; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
  .file-remove:hover { border-color: color-mix(in oklab, var(--ring) 36%, transparent); }

  /* single file picker */
  .single-picker { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
  .single-picker .name { color: var(--muted); }

  /* Upload arrastar-e-soltar */
.dropzone { 
  border: 2px dashed color-mix(in oklab, var(--muted) 26%, transparent);
  border-radius: 14px; 
  padding: 18px; 
  text-align: center; 
  color: var(--muted); 
}

/* Estado destacado */
.dropzone.is-dragover {
  background: color-mix(in oklab, var(--primary, #0ea5e9) 10%, transparent);
  border-color: var(--primary, #0ea5e9);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--primary, #0ea5e9) 35%, transparent) inset;
}

.dropzone .hint { opacity: .8; }  /* <-- fecha AQUI e só */

/* ===== Crop overlay (Recortar PDF ao vivo) ===== */
.viewer {
  position: relative;
  width: min(100%, 980px);
  margin-inline: auto;
  background: color-mix(in oklab, var(--muted) 8%, transparent);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
}
.viewer-toolbar {
  display: flex; align-items: center; gap: .5rem;
  padding: .75rem 1rem; justify-content: flex-end;
}
.viewer-toolbar .btn { min-width: auto; padding-inline: .7rem; }
.canvas-wrap { position: relative; overflow: auto; max-height: min(72vh, 900px); }
#pdfCanvas { display: block; margin: 0 auto; background: #fff; }

/* Overlay + máscara */
/* A posição (left/top/width/height) da overlay será sincronizada via JS */
.crop-layer { position: absolute; pointer-events: none; }
.crop-keep {
  position: absolute;
  outline: 2px solid var(--primary, #0ea5e9);
  box-shadow: 0 0 0 9999px rgba(2, 6, 23, .45);
  cursor: move;
  pointer-events: auto;
}

/* Alças */
.handle {
  position: absolute; width: 14px; height: 14px;
  border: 2px solid #fff; background: var(--primary, #0ea5e9);
  border-radius: 50%; box-shadow: 0 1px 6px rgba(0,0,0,.25);
  pointer-events: auto;
}
.handle.nw { top: -7px; left: -7px; cursor: nwse-resize; }
.handle.ne { top: -7px; right: -7px; cursor: nesw-resize; }
.handle.sw { bottom: -7px; left: -7px; cursor: nesw-resize; }
.handle.se { bottom: -7px; right: -7px; cursor: nwse-resize; }
.handle.n  { top: -7px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.handle.s  { bottom: -7px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.handle.w  { left: -7px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.handle.e  { right: -7px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }

@media (hover: none) { .handle { width: 18px; height: 18px; } }

.crop-info {
  position: absolute; right: 10px; top: 10px;
  background: rgba(2,6,23,.8); color: #fff; font-size: .75rem;
  padding: .25rem .5rem; border-radius: .5rem; pointer-events: none;
  }
/* ====== Crop: layout com miniaturas ====== */
.viewer-body { display: flex; gap: 12px; align-items: flex-start; }
.thumbs {
  width: 120px; max-height: min(72vh, 900px); overflow: auto;
  padding: 8px; border-right: 1px solid color-mix(in oklab, var(--muted) 22%, transparent);
  background: color-mix(in oklab, var(--muted) 6%, transparent);
  border-radius: 10px;
}
.thumb { display: block; border: 2px solid transparent; border-radius: 8px; margin-bottom: 8px; cursor: pointer; }
.thumb canvas { display: block; width: 100%; height: auto; border-radius: 6px; }
.thumb.active { border-color: var(--primary, #0ea5e9); box-shadow: 0 0 0 2px color-mix(in oklab, var(--primary) 40%, transparent); }

@media (max-width: 860px) {
  .viewer-body { flex-direction: column; }
  .thumbs { order: 2; width: 100%; max-height: 180px; display: grid; grid-auto-flow: column; grid-auto-columns: 100px; gap: 8px; overflow-x: auto; overflow-y: hidden; border-right: 0; }
  .thumb { margin: 0; }
}
/* === Miniaturas de PDF (Girar PDF) === */
.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin: 12px 0 16px;
}

.thumb-card {
  position: relative;
  border-radius: 12px;
  background: var(--card-bg, #fff);
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
  padding: 8px 8px 10px;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.thumb-head {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.icn {
  border: none;
  border-radius: 999px;
  width: 28px;
  height: 28px;
  font-size: 15px;
  line-height: 28px;
  text-align: center;
  background: rgba(0,0,0,.05);
  cursor: pointer;
}
.icn:hover { background: rgba(0,0,0,.1); }
.icn.danger { background: rgba(255,0,0,.08); }
.icn.danger:hover { background: rgba(255,0,0,.15); }

.thumb-canvas-wrap {
  position: relative;
  border-radius: 10px;
  background: #f4f4f5;
  overflow: hidden;
  display: grid;
  place-items: center;
  min-height: 180px; /* área protetora para a rotação caber */
}

.thumb-canvas {
  width: auto;
  height: 180px;
  transition: transform .2s ease;
  transform-origin: center center;
  display: block;
}

.thumb-caption {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted-fg, #6b7280);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}
.file-picker.dragging {
  outline: 2px dashed rgba(0,0,0,.25);
  outline-offset: 6px;
}
/* === Organizar PDF: botões de inserir página em branco === */
.thumb-card { position: relative; }
.thumb-card.dragging { opacity: .6; }

.insert-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 28px; height: 28px;
  border-radius: 999px;
  border: none;
  background: rgba(0,0,0,.05);
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 18px; line-height: 0;
}
.insert-btn:hover { background: rgba(0,0,0,.1); }
.insert-btn.left  { left: -14px; }
.insert-btn.right { right: -14px; }

/* quando houver bordas/espacamento, garanta área */
.thumb-canvas-wrap { position: relative; }

/* dropzone feedback */
.file-picker.dragging {
  outline: 2px dashed rgba(0,0,0,.25);
  outline-offset: 6px;
}
/* ==== Organizar PDF: deixa os "+" sempre visíveis ==== */
.organize .thumb-card { overflow: visible; touch-action: none;}
.organize .thumb-grid {
  -webkit-user-select: none;
  user-select: none;
}
.organize .insert-btn { z-index: 5; }
.organize .insert-btn.left  { left: -8px; }
.organize .insert-btn.right { right: -8px; }
.thumb-card.dragging { opacity: .6; }
/* ==== Organizar PDF: feedback de arraste ==== */
/* suaviza a animação do card quando "pegamos" */
.organize .thumb-card {
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
}

/* estado de arraste (tanto desktop quanto mobile) */
.organize .thumb-card.dragging {
  opacity: .9;
  transform: scale(.98);
  box-shadow: 0 10px 24px rgba(0,0,0,.28);
}

/* indicador visual de onde vai cair: antes/depois do card alvo */
.organize .thumb-card.drop-before::before,
.organize .thumb-card.drop-after::after {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--primary);
  border-radius: 3px;
}
.organize .thumb-card.drop-before::before { left: -3px; }
.organize .thumb-card.drop-after::after   { right: -3px; }

/* avatar que segue o dedo no mobile (Pointer Events) */
.drag-avatar {
  position: fixed;
  left: 0; top: 0;
  transform: translate(-45%, -55%) scale(.98);
  width: 160px;            /* mesmo alvo das thumbs */
  pointer-events: none;
  z-index: 9999;
  opacity: .95;
  filter: drop-shadow(0 10px 24px rgba(0,0,0,.28));
  will-change: transform, left, top;
}
/* garante que o canvas dentro do avatar escale e não "estoure" a caixa */
.drag-avatar canvas {
  width: 100%;
  height: auto;
  display: block;
}
/* Modal de recorte sempre por cima */
.scan-crop .crop-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 10000; backdrop-filter: blur(2px); }
.scan-crop .crop-dialog   { position: fixed; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: min(96vw, 900px); max-height: 92vh; background: var(--card-bg,#fff);
  border-radius: 14px; box-shadow: 0 15px 60px rgba(0,0,0,.35);
  display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; z-index: 10001;
}
.scan-crop .crop-body { padding: 8px 12px; overflow:auto; background: #111; }
#cropCanvas { max-width: 100%; display: block; margin: 0 auto; touch-action: none; }
.crop-handle { position:absolute; width:16px; height:16px; border:2px solid #fff; border-radius:50%; background:#2563eb; box-shadow:0 2px 8px rgba(0,0,0,.4); transform:translate(-50%,-50%); }
.crop-poly-edge { position:absolute; background:#2563eb; height:2px; transform-origin:0 0; opacity:.9; }
.crop-mask { position:absolute; background:rgba(0,0,0,.35); pointer-events:none; }

.ov-box:hover { background: rgba(34,197,94,.14); outline-color: #16a34a; }
.foot { 
  text-align: center;             /* forma simples e robusta */
  padding: 16px 12px;
}
/* Hero centralizado para páginas legais */
.page-legal .page-hero{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:10px;
  margin: 12px 0 20px;
  text-align:center;
}
.page-legal .page-hero .page-icon{
  width:40px; height:40px;
  opacity:.9;
  /* herda a cor do tema; ajuste se quiser */
  fill: currentColor;
}
.page-legal .page-hero h1{
  margin:0;
  line-height:1.1;
}

/* Seletor de idioma menor nessas páginas */
.page-legal .header-actions #langSelect.lang{
  font-size: 12px;
  height: 28px;
  padding: 0 28px 0 10px;
}
.external-links {
  display: grid;
  grid-template-columns: repeat(auto-fill,minmax(220px,1fr));
  gap: 12px;
}
.external-links .tool {
  display: block;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  padding: 12px;
}
.external-links .tool:hover { box-shadow: 0 4px 16px rgba(0,0,0,.06); }
.tool-head { display: flex; align-items: center; gap: 8px; }
.tool-ico { font-size: 18px; line-height: 1; opacity: .9; }
/* === Ads layout === */
.tool-layout {
  display: grid;
  grid-template-columns: minmax(0,1fr);
  gap: 16px;
}
.ad-rail { display: none; }

@media (min-width: 1200px) {
  .tool-layout {
    grid-template-columns: 300px minmax(0,1fr) 300px; /* L | conteúdo | R */
    align-items: start;
  }
  .ad-rail {
    display: block;
    position: sticky; 
    top: 88px;               /* abaixo do header fixo, ajuste se necessário */
  }
  .ad-rail .ad-slot {
    min-height: 250px;       /* evita CLS e espaços estranhos */
    margin: 16px 0;
  }
}

/* ad-slot já existe no seu CSS global; estes ajustes são neutros */
.ad-slot .adsbygoogle { width: 100%; }
