/* /css/imgresize.css */
/* NAMO TOOL 기존 도구 스타일 호환형 + 2열 입력 배치 + 넘침 보정 */

*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  --imgtool-primary: #2563eb;
  --imgtool-primary-dark: #1d4ed8;
  --imgtool-accent: #14b8a6;
  --imgtool-bg: #f5f7fa;
  --imgtool-text: #0f172a;
  --imgtool-muted: #64748b;
  --imgtool-line: #e5e7eb;
  --imgtool-border: #d7dde7;
  --imgtool-card-bg: #ffffff;
  --imgtool-radius: 18px;
  --imgtool-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  --imgtool-shadow-soft: 0 4px 14px rgba(15, 23, 42, 0.04);
}

.imgtool-wrap {
  max-width: 1140px;
  margin: 0.8rem auto 2rem;
  padding: 0;
  color: var(--imgtool-text);
  font-family: "Noto Sans KR", "Malgun Gothic", sans-serif;
}

/* 상단 대표 영역 */
.imgtool-hero {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 26px;
  background: #f8fafc;
  border: 1px solid #dbe3ef;
  border-radius: 24px;
  padding: 24px 26px;
  box-shadow: var(--imgtool-shadow-soft);
  margin-bottom: 18px;
}

.imgtool-hero-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.imgtool-hero-badge {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  padding: 8px 14px;
  border-radius: 999px;
  background: #e9effa;
  color: var(--imgtool-primary);
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}

.imgtool-hero h1 {
  margin: 0 0 10px;
  font-size: clamp(2rem, 3vw, 2.45rem);
  line-height: 1.18;
  font-weight: 900;
  letter-spacing: -0.04em;
  color: #0f172a;
}

.imgtool-hero p {
  margin: 0;
  max-width: 760px;
  color: #667085;
  font-size: 1.05rem;
  line-height: 1.75;
}

.imgtool-hero-visual {
  width: 220px;
  flex: 0 0 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.imgtool-hero-visual-box {
  width: 100%;
  min-height: 170px;
  border-radius: 24px;
  padding: 22px 20px;
  background: linear-gradient(135deg, #3b82f6 0%, #22c1c3 100%);
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: 0 16px 30px rgba(59, 130, 246, 0.22);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.imgtool-hero-visual-box::before {
  content: "";
  position: absolute;
  width: 90px;
  height: 90px;
  right: -20px;
  top: -16px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
}

.imgtool-hero-icon {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  font-weight: 900;
  margin-bottom: 14px;
  position: relative;
  z-index: 1;
}

.imgtool-hero-visual-text {
  position: relative;
  z-index: 1;
}

.imgtool-hero-visual-text strong {
  display: block;
  font-size: 1.1rem;
  font-weight: 900;
  margin-bottom: 6px;
}

.imgtool-hero-visual-text span {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.45;
  opacity: 0.96;
}

/* 안내 */
.imgtool-notice {
  background: #f1f8e9;
  border: 1px solid #c5e1a5;
  padding: 1rem 1.1rem;
  border-radius: 14px;
  margin-bottom: 1rem;
  font-size: 0.94rem;
  color: #334155;
  line-height: 1.7;
}

.imgtool-notice strong {
  color: #3f6212;
  font-weight: 800;
}

/* 레이아웃 */
.imgtool-layout {
  display: grid;
  grid-template-columns: 410px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.imgtool-left-panel,
.imgtool-right-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

/* 카드 */
.imgtool-card {
  background: var(--imgtool-card-bg);
  border: 1px solid var(--imgtool-line);
  border-radius: 18px;
  padding: 1.2rem;
  box-shadow: var(--imgtool-shadow-soft);
  min-width: 0;
  overflow: hidden;
}

.imgtool-card h2 {
  margin: 0 0 0.45rem;
  font-size: 1.25rem;
  color: #111827;
  font-weight: 800;
}

.imgtool-card-desc {
  margin: 0 0 1rem;
  color: var(--imgtool-muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

/* 업로드 */
.imgtool-upload-box {
  border: 2px dashed #cbd5e1;
  border-radius: 18px;
  padding: 24px 14px;
  text-align: center;
  background: #f8fafc;
  transition: 0.18s;
  cursor: pointer;
  display: block;
}

.imgtool-upload-box:hover {
  border-color: var(--imgtool-primary);
  background: #eff6ff;
}

.imgtool-upload-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 10px;
  border-radius: 18px;
  background: linear-gradient(135deg, #dbeafe, #cffafe);
  color: var(--imgtool-primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 900;
}

.imgtool-upload-box strong {
  display: block;
  font-size: 1.05rem;
  margin-bottom: 5px;
}

.imgtool-upload-box span {
  font-size: 0.82rem;
  color: var(--imgtool-muted);
}

#imageFile {
  display: none;
}

.imgtool-file-info {
  display: none;
  margin-top: 14px;
  background: #f1f5f9;
  border-radius: 12px;
  padding: 13px;
  font-size: 0.82rem;
  color: #334155;
  line-height: 1.7;
}

.imgtool-error-box {
  display: none;
  margin-top: 14px;
  border-radius: 14px;
  padding: 14px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  line-height: 1.7;
  font-size: 0.88rem;
}

/* 저장 형식 */
.imgtool-format-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.imgtool-format-btn {
  border: 1px solid #dbe3ef;
  background: #f8fafc;
  border-radius: 14px;
  padding: 13px 8px;
  cursor: pointer;
  text-align: center;
  transition: 0.18s;
  font-family: inherit;
  min-width: 0;
}

.imgtool-format-btn:hover {
  border-color: #93c5fd;
  background: #eff6ff;
}

.imgtool-format-btn.active {
  border-color: var(--imgtool-primary);
  background: #eff6ff;
  box-shadow: inset 0 0 0 1px var(--imgtool-primary);
}

.imgtool-format-btn strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 5px;
  color: #0f172a;
}

.imgtool-format-btn span {
  display: block;
  font-size: 0.75rem;
  color: var(--imgtool-muted);
  line-height: 1.45;
}

/* 변환 설정 */
.imgtool-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #eef2ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 0.82rem;
  font-weight: 900;
  margin-bottom: 14px;
}

.imgtool-mode-panel {
  display: none;
}

.imgtool-mode-panel.active {
  display: block;
}

.imgtool-mode-section-title {
  margin: 0 0 10px;
  font-size: 0.88rem;
  color: #334155;
  font-weight: 900;
}

.imgtool-preset-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.imgtool-preset-btn {
  border: 1px solid #dbe3ef;
  background: #f8fafc;
  border-radius: 10px;
  padding: 10px 6px;
  font-size: 0.82rem;
  font-weight: 900;
  color: #334155;
  cursor: pointer;
  transition: 0.18s;
  font-family: inherit;
  min-width: 0;
}

.imgtool-preset-btn:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: var(--imgtool-primary-dark);
}

/* 핵심 수정: 입력칸 2열 배치 */
.imgtool-option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
  min-width: 0;
}

.imgtool-option-grid.imgtool-mt {
  margin-top: 16px;
}

.imgtool-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.imgtool-field.full {
  grid-column: 1 / -1;
}

.imgtool-field label {
  font-size: 0.82rem;
  font-weight: 900;
  color: #334155;
}

.imgtool-field input,
.imgtool-field select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 42px;
  border: 1px solid #cbd5e1;
  border-radius: 11px;
  padding: 0 12px;
  font-size: 0.88rem;
  outline: none;
  background: #fff;
  font-family: inherit;
}

.imgtool-field input:focus,
.imgtool-field select:focus {
  border-color: var(--imgtool-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.imgtool-field input[readonly] {
  background: #f8fafc;
  color: var(--imgtool-muted);
}

.imgtool-range-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.imgtool-range-row input[type="range"] {
  flex: 1;
  min-width: 0;
}

.imgtool-range-value {
  min-width: 50px;
  text-align: right;
  font-weight: 900;
  color: var(--imgtool-primary);
}

.imgtool-helper-text {
  margin-top: 8px;
  font-size: 0.76rem;
  color: var(--imgtool-muted);
  line-height: 1.6;
}

.imgtool-check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 12px;
  border-radius: 12px;
  font-size: 0.88rem;
  color: #334155;
}

.imgtool-check-row input {
  width: 18px;
  height: 18px;
}

/* 미리보기 */
.imgtool-preview-card {
  min-height: 560px;
}

.imgtool-compare-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.imgtool-preview-panel {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 14px;
  min-height: 330px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.imgtool-preview-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.imgtool-preview-title strong {
  font-size: 0.94rem;
  color: #0f172a;
}

.imgtool-preview-title span {
  font-size: 0.76rem;
  color: var(--imgtool-muted);
}

.imgtool-preview-image-box {
  flex: 1;
  border-radius: 14px;
  background:
    linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
    linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 260px;
}

.imgtool-preview-image-box.empty {
  background: #f1f5f9;
}

.imgtool-preview-image-box img {
  max-width: 100%;
  max-height: 300px;
  object-fit: contain;
  display: block;
}

.imgtool-empty-text {
  color: #94a3b8;
  font-size: 0.88rem;
  text-align: center;
  line-height: 1.6;
}

/* 요약 */
.imgtool-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.imgtool-summary-grid.single-row {
  grid-template-columns: 1fr;
  margin-top: 10px;
}

.imgtool-summary-item {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 13px;
  padding: 13px;
  min-width: 0;
}

.imgtool-summary-item span {
  display: block;
  font-size: 0.76rem;
  color: var(--imgtool-muted);
  margin-bottom: 5px;
}

.imgtool-summary-item strong {
  display: block;
  font-size: 0.92rem;
  color: #0f172a;
  word-break: break-word;
}

.imgtool-summary-item.good strong {
  color: #16a34a;
}

.imgtool-btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.imgtool-btn {
  border: 0;
  border-radius: 12px;
  padding: 13px 18px;
  font-size: 0.94rem;
  font-weight: 900;
  cursor: pointer;
  transition: 0.18s;
  font-family: inherit;
}

.imgtool-btn.green {
  background: #16a34a;
  color: #fff;
}

.imgtool-btn.green:hover {
  background: #15803d;
}

.imgtool-btn.gray {
  background: #e2e8f0;
  color: #334155;
}

.imgtool-btn.gray:hover {
  background: #cbd5e1;
}

.imgtool-btn:disabled {
  background: #cbd5e1;
  color: var(--imgtool-muted);
  cursor: not-allowed;
}

/* 팁 */
.imgtool-tip-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.imgtool-tip-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 13px;
  padding: 13px;
  min-width: 0;
}

.imgtool-tip-item strong {
  display: block;
  color: #0f172a;
  margin-bottom: 5px;
  font-size: 0.82rem;
}

.imgtool-tip-item span {
  color: var(--imgtool-muted);
  font-size: 0.76rem;
  line-height: 1.5;
}

/* 반응형 */
@media (max-width: 1040px) {
  .imgtool-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .imgtool-hero {
    flex-direction: column;
  }

  .imgtool-hero-visual {
    width: 100%;
    flex: 0 0 auto;
    justify-content: flex-start;
  }

  .imgtool-hero-visual-box {
    width: 240px;
  }
}

@media (max-width: 760px) {
  body,
  html {
    margin: 0 !important;
    padding: 0 !important;
    overflow-x: hidden;
  }

  .imgtool-wrap {
    width: 100%;
    margin: 0 auto 24px;
    padding: 0 10px;
  }

  .imgtool-hero {
    padding: 18px;
    border-radius: 20px;
    gap: 16px;
  }

  .imgtool-hero h1 {
    font-size: 1.7rem;
  }

  .imgtool-hero p {
    font-size: 0.95rem;
    line-height: 1.65;
  }

  .imgtool-hero-visual-box {
    width: 100%;
    min-height: 140px;
    border-radius: 20px;
  }

  .imgtool-format-grid,
  .imgtool-compare-grid,
  .imgtool-summary-grid,
  .imgtool-tip-grid,
  .imgtool-option-grid {
    grid-template-columns: 1fr;
  }

  .imgtool-field.full {
    grid-column: auto;
  }

  .imgtool-preset-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .imgtool-btn {
    width: 100%;
  }
}