/* 이미지 리사이저 화면의 레이아웃과 반응형 테마를 정의한다 */
:root {
  color-scheme: light;
  --bg: #edf2f7;
  --surface: #ffffff;
  --surface-strong: #f8fafc;
  --text: #172033;
  --muted: #64748b;
  --line: #d8e1ec;
  --brand: #0f766e;
  --brand-strong: #0b5f59;
  --accent: #eab308;
  --danger: #dc2626;
  --ok: #15803d;
  --shadow: 0 20px 60px rgba(15, 23, 42, 0.12);
}

body.dark {
  color-scheme: dark;
  --bg: #111827;
  --surface: #182235;
  --surface-strong: #202b40;
  --text: #eef4ff;
  --muted: #a8b3c7;
  --line: #334158;
  --brand: #2dd4bf;
  --brand-strong: #5eead4;
  --accent: #facc15;
  --danger: #f87171;
  --ok: #86efac;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(20, 184, 166, 0.18), transparent 32rem),
    linear-gradient(135deg, var(--bg), var(--surface-strong));
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.workspace {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.8rem, 3vw, 3rem);
}

h2 {
  font-size: 1.15rem;
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  cursor: pointer;
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 0;
}

.upload-panel {
  padding: 24px;
  border-right: 1px solid var(--line);
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 190px;
  padding: 24px;
  border: 2px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 10%, var(--surface-strong));
  transform: translateY(-1px);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  border-radius: 999px;
  background: var(--brand);
  color: #ffffff;
  font-size: 1.55rem;
  font-weight: 700;
}

.drop-zone strong {
  font-size: 1.05rem;
}

.drop-zone small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.preview-stack {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.preview-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.preview-header span {
  color: var(--muted);
  font-weight: 700;
}

.preview-header strong {
  font-size: 0.92rem;
  white-space: nowrap;
}

.image-frame {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 260px;
  aspect-ratio: 4 / 3;
  background:
    linear-gradient(45deg, color-mix(in srgb, var(--line) 35%, transparent) 25%, transparent 25%),
    linear-gradient(-45deg, color-mix(in srgb, var(--line) 35%, transparent) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, color-mix(in srgb, var(--line) 35%, transparent) 75%),
    linear-gradient(-45deg, transparent 75%, color-mix(in srgb, var(--line) 35%, transparent) 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
}

.image-frame img {
  display: none;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.image-frame img.has-image {
  display: block;
}

.empty-state {
  color: var(--muted);
  font-weight: 700;
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin: 0;
  background: var(--line);
}

.meta-grid div {
  min-width: 0;
  padding: 12px;
  background: var(--surface);
}

.meta-grid dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.meta-grid dd {
  margin: 0;
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.control-panel {
  padding: 24px;
  background: color-mix(in srgb, var(--surface-strong) 76%, var(--surface));
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}

#statusBadge {
  flex: 0 0 auto;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.field-group {
  margin-bottom: 16px;
}

.field-group label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.input-unit,
.target-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.input-unit input,
.target-row input,
.target-row select {
  min-width: 0;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--text);
  outline: none;
}

.input-unit input,
.target-row input {
  width: 100%;
  padding: 0 12px;
  font-weight: 700;
}

.input-unit span {
  padding: 0 12px;
  color: var(--muted);
  font-weight: 800;
}

.target-row select {
  padding: 0 10px;
  border-left: 1px solid var(--line);
  cursor: pointer;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin: 4px 0 18px;
  color: var(--text);
  font-weight: 700;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.summary-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 22px 0;
}

.summary-strip div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.summary-strip span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.summary-strip strong {
  display: block;
  overflow-wrap: anywhere;
}

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #ffffff;
  cursor: pointer;
  font-weight: 900;
  transition: background 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}

.primary-action:hover:not(:disabled) {
  background: var(--brand-strong);
  transform: translateY(-1px);
}

.primary-action:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.helper-text {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.is-ok {
  color: var(--ok);
}

.is-warn {
  color: var(--danger);
}

@media (max-width: 920px) {
  .tool-grid {
    grid-template-columns: 1fr;
  }

  .upload-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 10px 0;
  }

  .app-header,
  .upload-panel,
  .control-panel {
    padding: 18px;
  }

  .preview-stack {
    grid-template-columns: 1fr;
  }

  .image-frame {
    min-height: 220px;
  }

  .meta-grid,
  .summary-strip {
    grid-template-columns: 1fr;
  }
}
