/* 이미지 도구 공통 디자인 (IK) */
.ik { overflow-x: clip; }
.ik [hidden] { display: none !important; }
.ik-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.ik-main { position: sticky; top: 86px; display: grid; gap: 14px; min-width: 0; }
.ik-side { display: grid; gap: 14px; min-width: 0; }
.ik-side .tool-panel, .ik-main.tool-panel { padding: clamp(16px, 2.6vw, 24px); }
.ik-side .field:last-child { margin-bottom: 0; }

/* 파일 넣는 상자 */
.ik-drop { position: relative; display: grid; place-items: center; gap: 6px; min-height: 220px; padding: 28px 18px; border: 2px dashed color-mix(in srgb, var(--primary) 45%, var(--line)); border-radius: var(--r-lg); background: color-mix(in srgb, var(--primary) 4%, var(--surface)); text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.ik-drop:hover, .ik-drop.is-over { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 9%, var(--surface)); }
.ik-drop input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.ik-drop-icon { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 18px; background: var(--surface); box-shadow: var(--sh-sm); font-size: 28px; }
.ik-drop b { font-size: 17px; letter-spacing: -.02em; }
.ik-drop small { color: var(--muted); font-size: 13.5px; line-height: 1.6; word-break: keep-all; }
.ik-drop.compact { min-height: 0; padding: 14px; grid-auto-flow: column; justify-content: center; gap: 10px; }
.ik-drop.compact .ik-drop-icon { width: 38px; height: 38px; border-radius: 12px; font-size: 19px; }

/* 미리보기 무대 */
.ik-stage { position: relative; display: grid; place-items: center; min-height: 240px; border-radius: var(--r-md); border: 1px solid var(--line); overflow: hidden; background: repeating-conic-gradient(#eef1f2 0% 25%, #ffffff 0% 50%) 50% / 20px 20px; }
:root[data-theme="dark"] .ik-stage { background: repeating-conic-gradient(#2a3437 0% 25%, #222b2e 0% 50%) 50% / 20px 20px; }
.ik-stage canvas, .ik-stage img { display: block; max-width: 100%; max-height: 68vh; height: auto; }
.ik-stage.plain { background: color-mix(in srgb, var(--text) 4%, var(--surface)); }
.ik-stage .ik-touch { touch-action: none; cursor: crosshair; }
.ik-cap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; color: var(--muted); font-size: 13.5px; }
.ik-cap b { color: var(--text); font-variant-numeric: tabular-nums; }

/* 선택 칩 · 색 · 범위 */
.ik-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ik-chip { position: relative; }
.ik-chip input { position: absolute; left: 0; top: 0; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.ik-chip span { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 14px; border: 1.5px solid var(--line); border-radius: 99px; background: var(--surface); font-size: 15px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: border-color .15s, background .15s; }
.ik-chip span small { color: var(--subtle); font-weight: 500; font-size: 12.5px; }
.ik-chip input:checked + span { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 9%, var(--surface)); color: var(--link); }
.ik-chip input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.ik-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.ik-card { position: relative; }
.ik-card input { position: absolute; left: 0; top: 0; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.ik-card span { display: grid; gap: 2px; height: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: var(--r-md); background: var(--surface); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.ik-card b { font-size: 14px; letter-spacing: -.02em; line-height: 1.35; }
.ik-card small { color: var(--subtle); font-size: 12px; line-height: 1.4; font-variant-numeric: tabular-nums; word-break: keep-all; }
.ik-card input:checked + span { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent); }
.ik-card input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

.ik-colors { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ik-color { position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); cursor: pointer; }
.ik-color input[type=radio] { position: absolute; left: 0; top: 0; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.ik-color i { width: 26px; height: 26px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.ik-color:has(input:checked) { border-color: var(--text); }
.ik-color input[type=color] { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.ik-color.rainbow i { background: conic-gradient(#e33, #fc3, #3c6, #39f, #93f, #e33); }

.ik-ranges { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.ik-range { display: grid; gap: 6px; font-size: 14px; font-weight: 700; }
.ik-range > span { display: flex; justify-content: space-between; gap: 8px; }
.ik-range output { color: var(--link); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ik-range input[type=range] { width: 100%; accent-color: var(--primary); touch-action: pan-y; }
.ik-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ik-row > .field { flex: 1 1 140px; margin-bottom: 0; }
.ik-check { display: inline-flex; align-items: center; gap: 8px; font-size: 14.5px; font-weight: 600; cursor: pointer; }
.ik-check input { width: 18px; height: 18px; accent-color: var(--primary); }

.ik-actions { display: grid; grid-template-columns: 1.4fr 1fr; gap: 8px; }
.ik-actions .btn { min-height: 50px; font-size: 16px; }
.ik-actions .btn:only-child { grid-column: 1 / -1; }
.ik-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.ik-note { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.7; word-break: keep-all; }
.ik-warn { padding: 10px 12px; border-radius: var(--r-sm); background: color-mix(in srgb, var(--sun) 16%, var(--surface)); color: var(--text); font-size: 13.5px; line-height: 1.6; }
.ik-privacy { margin: 16px 2px 0; }
.ik select, .ik input[type=text], .ik input[type=number], .ik input[type=url], .ik input[type=tel], .ik input[type=email], .ik textarea { font-size: 16px; }

@media (hover: hover) { .ik-card:hover span, .ik-chip:hover span { border-color: var(--line-strong); } }
@media (max-width: 900px) {
  .ik-layout { grid-template-columns: 1fr; }
  .ik-main { position: static; }
}
@media (max-width: 520px) {
  .ik-ranges { grid-template-columns: 1fr; }
  .ik-actions { grid-template-columns: 1fr; }
  .ik-drop { min-height: 180px; }
  .ik-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
