:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #242128;
  background: #f7f5f7;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --magenta: #a90068;
  --magenta-dark: #850052;
  --border: #ded9df;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 280px;
  min-height: 100vh;
  margin: 0;
}

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

.app-header {
  margin-bottom: 24px;
  text-align: center;
}

.app-header h1 {
  margin: 0;
  color: var(--magenta);
  font-size: clamp(2rem, 8vw, 3rem);
  line-height: 1.1;
}

.app-header p {
  margin: 8px 0 0;
  color: #625c65;
}

.actions {
  display: grid;
  gap: 12px;
  width: min(100%, 440px);
  margin: 0 auto;
}

.button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 11px 20px;
  border: 2px solid transparent;
  border-radius: 12px;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:focus-visible,
.image-action:focus-visible,
.visually-hidden:focus-visible + .button-primary {
  outline: 3px solid #252129;
  outline-offset: 3px;
}

.button-primary {
  color: #fff;
  background: var(--magenta);
}

.button-primary:hover {
  background: var(--magenta-dark);
}

.button-secondary {
  color: var(--magenta);
  border-color: var(--magenta);
  background: #fff;
}

.button-secondary:hover:not(:disabled) {
  background: #fff1f8;
}

.button:disabled {
  color: #77717a;
  border-color: #d7d2d8;
  background: #e9e6e9;
  cursor: not-allowed;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.status {
  min-height: 1.5em;
  margin: 20px 0;
  color: #625c65;
  text-align: center;
}

.image-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr));
  gap: 16px;
}

.image-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 2px 8px rgb(34 24 34 / 6%);
}

.preview-frame {
  position: relative;
  display: grid;
  aspect-ratio: 3 / 4;
  place-items: center;
  overflow: hidden;
  padding: 10px;
  background-color: #efedf0;
  background-image: linear-gradient(45deg, #e3e0e5 25%, transparent 25%),
    linear-gradient(-45deg, #e3e0e5 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e3e0e5 75%),
    linear-gradient(-45deg, transparent 75%, #e3e0e5 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.preview-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 1px 5px rgb(0 0 0 / 15%);
}

.image-controls {
  position: absolute;
  top: 16px;
  right: 16px;
  left: 16px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

.image-action {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgb(35 30 36 / 78%);
  font: inherit;
  font-size: 1.4rem;
  cursor: pointer;
  pointer-events: auto;
}

.image-action:hover {
  background: #28222a;
}

.image-name {
  overflow-wrap: anywhere;
  margin: 0;
  padding: 11px 12px 13px;
  font-size: 0.9rem;
  font-weight: 600;
}

@media (min-width: 600px) {
  .app {
    padding-top: 48px;
  }

  .actions {
    grid-template-columns: 1fr 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
