.image-tool-main {
  padding: 20px;
}

.img-tool {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 18px;
  align-items: start;
  grid-template-areas: "controls preview";
}

.img-tool__controls,
.img-tool__preview {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(8px);
}

.img-tool__controls {
  padding: 16px;
  grid-area: controls;
}

.img-tool__subtitle {
  margin: 4px 0 12px;
  color: #475569;
  font-size: 13px;
}

.img-tool__dropzone {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px dashed #94a3b8;
  background: #f8fafc;
  border-radius: 14px;
  padding: 16px;
  cursor: pointer;
  transition: background-color var(--duration-base) var(--ease-out), color var(--duration-base) var(--ease-out), box-shadow var(--duration-base) var(--ease-out), transform var(--duration-fast) var(--ease-out);
}

.img-tool__dropzone:hover,
.img-tool__dropzone.is-active {
  border-color: #3b82f6;
  background: #eff6ff;
}

.img-tool__meta {
  margin-top: 10px;
  font-size: 12px;
  color: #334155;
}

.img-tool__group {
  margin-top: 14px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: rgba(248, 250, 252, 0.9);
}

.img-tool__group-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 10px;
}

.img-tool__row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.img-tool__row label {
  flex: 1;
  font-size: 12px;
  color: #334155;
}

.img-tool input,
.img-tool select,
.img-tool button {
  width: 100%;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  padding: 10px 12px;
  font-size: 13px;
  transition: background-color var(--duration-base) var(--ease-out), color var(--duration-base) var(--ease-out), box-shadow var(--duration-base) var(--ease-out), transform var(--duration-fast) var(--ease-out);
}

.img-tool button {
  background: #111827;
  color: #fff;
  border-color: #111827;
  cursor: pointer;
}

.img-tool button:hover {
  background: #1f2937;
}

.img-tool button.is-active {
  background: #2563eb;
  border-color: #2563eb;
}

.img-tool__checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.img-tool__checkbox input {
  width: auto;
  padding: 0;
}

.img-tool__grow {
  flex: 1;
}

.img-tool__preview {
  padding: 16px;
  grid-area: preview;
  position: sticky;
  top: 12px;
}

.img-tool__canvas-wrap {
  position: relative;
  height: min(70vh, 560px);
  border-radius: 14px;
  border: 1px solid #dbeafe;
  background: #0f172a;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.img-tool__canvas-wrap.is-dragging {
  cursor: grabbing;
}

.img-tool__loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.5);
  color: #fff;
  font-size: 14px;
  opacity: 1;
  pointer-events: all;
  transition: opacity 0.2s ease;
}

.img-tool__loading.hidden {
  opacity: 0;
  pointer-events: none;
}

#previewCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.img-tool__viewport-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.15) 1px, transparent 1px) 0 0/100% 33.33%,
    linear-gradient(90deg, rgba(255, 255, 255, 0.15) 1px, transparent 1px) 0 0/33.33% 100%;
  box-shadow: inset 0 0 0 9999px rgba(2, 6, 23, 0.28);
}

.img-tool__pct-btn {
  background: #1e293b !important;
}

@media (max-width: 1024px) {
  .img-tool {
    grid-template-columns: 1fr;
    grid-template-areas:
      "preview"
      "controls";
  }
  .img-tool__preview {
    position: static;
  }
  .img-tool__canvas-wrap {
    height: min(55vh, 420px);
  }
}