/* Reset: box sizing consistente */
*, *::before, *::after { box-sizing: border-box; }

:root{ --gap:12px; --ui-size:44px; }

/* ===== Altura total disponível ===== */
html, body { height: 100%; }

body{
  font-family:system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  margin:18px;
  user-select:none;
  background:#fafafa;
  color:#222;
}

h1{ margin:0 0 10px 0; font-size:18px; }
h2{ margin:18px 0 8px; font-size:16px; }

/* ===== LAYOUT (sempre em coluna: Galeria em cima, Editor embaixo) ===== */


/* ===== CONTROLES + EDITOR ===== */
/* painel do editor vira grid para dar altura fixa sobrante ao wrapper */


#controls{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  align-items:center;
}

#wrapper{
  width:100%;
  height:100%;              /* ocupa 100% da linha 1fr */
  position:relative;
  background:#fff;
  overflow:hidden;
  touch-action:none;
  min-height: 0;            /* impede overflow vertical forçar crescimento */
}

canvas{
  width:100%;
  height:100%;              /* preenche todo o #wrapper */
  /* aspect-ratio removido para não forçar 1:1 do canvas inteiro */
  display:block;
  background:#fafafa;
  cursor:grab;
}
canvas:active{ cursor:grabbing; }

#overlayReference{
  position:absolute; left:0; top:0; width:0; height:0;
  pointer-events:none;
  border:2px solid rgba(25, 0, 255, 0.95);
  opacity:0.5; display:block;
  background-size:contain;
  background-repeat:no-repeat;
  background-position:center;
}
#overlayReference > .ov-pad{
  padding:5%;
  width:100%;
  height:100%;
  pointer-events:none;
}
#overlayReference > .ov-pad > .ov-box{
  width:100%;
  height:100%;
  border:3px solid rgb(0, 0, 0);
  border-radius: 12%;
  pointer-events:none;
}

/* Lista de camadas */
#camadasList{
  overflow: auto; /* rolagem própria; não empurra o wrapper */
  overflow-x: hidden; /* não empurra a altura do editor; rola se precisar */
  margin-top:10px;
  display:flex;
  flex-direction:column;
  gap:6px;
  max-width:400px;
  max-height: 500px;
  position: absolute;
  bottom: 0;
  left: 0;
}
.camada-item{
  display:grid;
  grid-template-columns: 48px auto;
  grid-template-rows: auto auto;
  column-gap: 5px;
  align-items:center;
  padding:5px;
  border-radius:8px;
  background: rgb(246 59 222 / 50%);
  color: white
  
}
.camada-item.active{ 
  background: rgb(59 130 246 / 0.5); 
}
.thumb{
  width:48px; height:48px;
  object-fit:cover; border-radius:6px;;
  grid-row: 1 / span 2;
}
.camada-header{ display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.camada-actions{ display:flex; gap:6px; flex-wrap:wrap; }
.camada-controls{ display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.camada-item button{     padding: 4px 6px;
    cursor: pointer;
    border: 1px solid white;
    border-radius: 6px; }
.blur-control{ width:220px; flex: 1 1 220px; }
.blur-value{ min-width:48px; text-align:right; font-variant-numeric: tabular-nums; color:#444; }

button, input[type="color"]{ padding:6px 10px; }
small{ font-size:12px; color:#555; display:block; margin-top:6px; }
label.inline{ display:flex; align-items:center; gap:6px; }

/* Barra do editor (ação de salvar no item da galeria) */
#editorBar{}
#saveToGalleryBtn[disabled]{ opacity:0.5; cursor:not-allowed; }

/* ===== GALERIA ===== */

#galleryControls{
  display:flex;
  gap:8px;
  align-items:center;
  flex-wrap:wrap;
}

#dropZone.dragover{
  border-color:#666;
  background:#f4f4f4;
  color:#222;
}
#galleryGrid{
  
}
.g-item{
  border:1px solid #080808;
  overflow:hidden;
  display:flex;
  flex-direction:column;
}
.g-thumb{
  display:block;
  max-width:100%;
  width:auto;
  height:auto;
  margin:0 auto;
  background:#f2f2f2;
}
.g-meta{
  display:flex;
  flex-direction:column;
}

.g-actions{
  display:flex;
}
.g-actions button{
  padding:6px 8px;
  font-size:12px;
  background-color: #333333;
  flex-shrink: 0;
  flex-grow: 1;
  color: #888;
}


button[data-action="open"] {
  background: green;
  color: white;
}


.muted{ color:#777; font-size:12px; }
