:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f6f8;
  color: #1f2328;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f5f6f8;
}

button {
  font: inherit;
}

.app {
  width: min(1080px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

.topbar p {
  margin-top: 8px;
  color: #667085;
}

.primary,
.upload-button,
.remove-button,
.secondary {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.primary {
  min-width: 120px;
  padding: 11px 18px;
  background: #176b5b;
  color: #fff;
}

.primary:disabled {
  cursor: not-allowed;
  background: #a5b8b3;
}

.secondary {
  padding: 10px 14px;
  border: 1px solid #cbd3dc;
  background: #fff;
  color: #1f2328;
}

.upload-panel {
  display: grid;
  place-items: center;
  min-height: 180px;
  border: 2px dashed #bac4d0;
  border-radius: 8px;
  background: #fff;
  transition: border-color 150ms ease, background 150ms ease;
}

.upload-panel.is-dragging {
  border-color: #176b5b;
  background: #eef8f5;
}

.upload-button {
  padding: 10px 18px;
  background: #1f2328;
  color: #fff;
}

.upload-panel p {
  margin-top: 10px;
  color: #667085;
}

.workspace {
  margin-top: 20px;
}

.image-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.image-list-header h2 {
  font-size: 18px;
}

.image-list-header span {
  color: #667085;
}

.image-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.image-item {
  display: grid;
  grid-template-columns: 44px 88px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 96px;
  padding: 10px;
  border: 1px solid #d7dde5;
  border-radius: 8px;
  background: #fff;
}

.image-item.is-dragging {
  opacity: 0.45;
}

.drag-handle {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #eef1f5;
  color: #667085;
  cursor: grab;
  user-select: none;
}

.thumb-button {
  width: 88px;
  height: 72px;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 6px;
  background: #eef1f5;
  cursor: zoom-in;
}

.thumb-button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-meta {
  min-width: 0;
}

.image-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.image-size {
  margin-top: 6px;
  color: #667085;
  font-size: 14px;
}

.remove-button {
  padding: 8px 12px;
  background: #f2d7d5;
  color: #8d1e16;
}

.result-panel {
  margin-top: 20px;
  padding: 16px;
  border: 1px solid #d7dde5;
  border-radius: 8px;
  background: #fff;
}

.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.result-header h2 {
  font-size: 18px;
}

.result-header p {
  margin-top: 6px;
  color: #667085;
}

.result-actions {
  display: flex;
  gap: 10px;
}

.result-preview {
  display: block;
  width: 100%;
  max-height: 520px;
  padding: 0;
  overflow: auto;
  border: 1px solid #d7dde5;
  border-radius: 8px;
  background: #f5f6f8;
  cursor: zoom-in;
}

.result-preview img {
  display: block;
  width: min(100%, 720px);
  height: auto;
  margin: 0 auto;
}

.preview-dialog {
  width: min(980px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: #111;
}

.preview-dialog::backdrop {
  background: rgb(0 0 0 / 0.72);
}

.preview-dialog img {
  display: block;
  width: 100%;
  max-height: calc(100vh - 32px);
  object-fit: contain;
}

.close-preview {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.9);
  color: #1f2328;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

@media (max-width: 680px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .primary {
    width: 100%;
  }

  .result-header {
    flex-direction: column;
  }

  .result-actions {
    width: 100%;
  }

  .result-actions button {
    flex: 1;
  }

  .image-item {
    grid-template-columns: 36px 72px minmax(0, 1fr);
  }

  .thumb-button {
    width: 72px;
    height: 60px;
  }

  .remove-button {
    grid-column: 2 / -1;
    justify-self: start;
  }
}
