.gridcut-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.9fr);
  gap: 16px;
  align-items: start;
}

.gridcut-main,
.gridcut-side {
  display: grid;
  gap: 16px;
}

.tool-block {
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid #e4e8ef;
  border-radius: 24px;
  background:
    radial-gradient(circle at top right, rgba(198, 225, 255, 0.34), transparent 34%),
    linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
}

.section-head,
.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.section-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 38px;
  padding: 0 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, #eef7ff 0%, #deebff 100%);
  color: #204a74;
  font-size: 14px;
  font-weight: 700;
  border: 1px solid #c8dcf6;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.section-pill-soft {
  background: linear-gradient(180deg, #f7fbff 0%, #edf5ff 100%);
  border-color: #dbe8fa;
  color: #325d89;
}

.pill-meta,
.result-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  background: #f4f7fb;
  border: 1px solid #dbe3ef;
  color: #526173;
  font-size: 13px;
  font-weight: 600;
}

.gridcut-dropzone {
  display: grid;
  gap: 8px;
  padding: 20px 22px;
  border-radius: 22px;
  border: 1px dashed #8fb0d5;
  background:
    radial-gradient(circle at top left, rgba(90, 144, 213, 0.12), transparent 44%),
    linear-gradient(180deg, #f8fbff 0%, #f3f7fd 100%);
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.gridcut-dropzone:hover,
.gridcut-dropzone.is-dragover {
  transform: translateY(-1px);
  border-color: #4277b1;
  box-shadow: 0 16px 28px -24px rgba(49, 90, 138, 0.92);
}

.gridcut-dropzone strong {
  font-size: 16px;
  line-height: 1.5;
  color: #173c66;
}

.gridcut-dropzone span,
.gridcut-dropzone em {
  color: #5a6f83;
  line-height: 1.8;
}

.gridcut-dropzone em {
  font-style: normal;
  font-size: 12px;
}

.gridcut-dropzone input[type='file'] {
  display: none;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.control {
  display: grid;
  gap: 8px;
}

.control > span {
  color: #415366;
  font-size: 13px;
  font-weight: 600;
}

.control input[type='range'],
.control select {
  width: 100%;
}

.control select {
  height: 42px;
  border: 1px solid #d7deea;
  border-radius: 12px;
  padding: 0 12px;
  background: #fff;
  color: #1f2937;
}

.control-tip {
  padding: 12px 14px;
  border-radius: 18px;
  background: #f7fafc;
  border: 1px solid #e2e8f0;
}

.control-tip p {
  margin: 0;
  color: #5b6978;
  line-height: 1.7;
  font-size: 13px;
}

.range-value {
  color: #0f5f9a;
  font-size: 13px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.action-row button {
  border: 1px solid #cfd7e4;
  background: #f8fafc;
  color: #334155;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.action-row button:hover:not(:disabled) {
  background: #eef4fb;
  transform: translateY(-1px);
}

.action-row button.primary {
  background: #1f7a45;
  border-color: #1f7a45;
  color: #fff;
}

.action-row button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.tool-tip {
  min-height: 20px;
  color: #334155;
  font-size: 13px;
  line-height: 1.6;
}

.tool-tip.error {
  color: #b42318;
}

.preview-shell {
  position: relative;
  min-height: 420px;
  border-radius: 26px;
  overflow: hidden;
  border: 1px solid #dbe4ef;
  background:
    linear-gradient(45deg, #f8fbff 25%, transparent 25%) -14px 0/28px 28px,
    linear-gradient(-45deg, #f8fbff 25%, transparent 25%) -14px 0/28px 28px,
    linear-gradient(45deg, transparent 75%, #f8fbff 75%) -14px 0/28px 28px,
    linear-gradient(-45deg, transparent 75%, #f8fbff 75%) -14px 0/28px 28px,
    #eef3f9;
}

#preview-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 420px;
}

.preview-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: #6b7280;
  line-height: 1.8;
  pointer-events: none;
}

.preview-empty[hidden] {
  display: none !important;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.stat-card {
  border: 1px solid #e1e6ef;
  border-radius: 16px;
  background: #fff;
  padding: 10px 12px;
  display: grid;
  gap: 4px;
}

.stat-card span {
  color: #66758b;
  font-size: 12px;
}

.stat-card strong {
  color: #111827;
  font-size: 15px;
  line-height: 1.3;
}

.result-box {
  min-height: 188px;
  border: 1px solid #dbe2ed;
  border-radius: 18px;
  padding: 14px 16px;
  resize: vertical;
  line-height: 1.75;
  background: #f9fbfe;
  color: #1f2937;
}

.slice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.slice-empty {
  grid-column: 1 / -1;
  min-height: 132px;
  display: grid;
  place-items: center;
  padding: 20px;
  border-radius: 18px;
  border: 1px dashed #d8e0ea;
  background: #f8fafc;
  color: #6b7280;
  text-align: center;
}

.slice-card {
  display: grid;
  gap: 10px;
  padding: 10px;
  border-radius: 18px;
  background: #ffffff;
  border: 1px solid #e1e7f0;
  box-shadow: 0 8px 24px -24px rgba(15, 23, 42, 0.45);
}

.slice-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 14px;
  background: #eef2f7;
}

.slice-card h3 {
  margin: 0;
  font-size: 13px;
  color: #24364a;
}

.slice-card p {
  margin: 0;
  color: #64748b;
  font-size: 12px;
  line-height: 1.6;
}

.slice-card a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid #cfe0f1;
  background: #edf6ff;
  color: #17558b;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

@media (max-width: 1080px) {
  .gridcut-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .control-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .tool-block,
  .gridcut-dropzone,
  .preview-shell,
  .result-box,
  .slice-card {
    border-radius: 18px;
  }

  .control-grid,
  .stats-grid,
  .slice-grid {
    grid-template-columns: 1fr;
  }

  #preview-canvas,
  .preview-shell {
    min-height: 300px;
  }
}
