body {
  font-family: system-ui, Arial, sans-serif;
  margin: 20px;
}

.row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.workspace {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 16px;
  align-items: start;
}

.canvas {
  position: relative;
  border: 1px solid #ddd;
  min-height: 620px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #fafafa;
}

#preview {
  max-width: 100%;
  max-height: 860px;
  display: block;
}

.box {
  position: absolute;
  border: 2px dashed #111;
  background: rgba(0, 0, 0, 0.06);
  box-sizing: border-box;
}

.hidden {
  display: none;
}

.handle {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #111;
  border-radius: 3px;
}

.handle.br {
  right: -7px;
  bottom: -7px;
  cursor: nwse-resize;
}

.panel {
  border: 1px solid #ddd;
  padding: 10px;
  border-radius: 8px;
}

.result {
  display: block;
  max-width: 320px;
  width: 100%;
  height: auto;
  border: 1px solid #ddd;
  margin-top: 8px;
}

.box { cursor: grab; }

/* Responsive adjustments for mobile */
@media (max-width: 720px) {
  body { margin: 12px; }
  .workspace {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .canvas {
    min-height: 440px;
    padding: 8px;
  }

  .panel {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
  }

  .row { flex-wrap: wrap; gap: 8px; }

  input[type="number"], input[type="file"], button {
    font-size: 16px;
    padding: 10px 12px;
  }

  .handle {
    width: 20px;
    height: 20px;
    right: -10px;
    bottom: -10px;
  }

  #preview { max-height: 520px; }

  /* Make result preview full width within the panel on mobile */
  .result { max-width: 100%; }
}
