* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: #faf6f2;
  color: #333;
  display: flex;
  justify-content: center;
  padding: 1.5rem;
}

main {
  width: 100%;
  max-width: 34rem;
}

h1 {
  font-size: 1.4rem;
  text-align: center;
  margin-bottom: 1.5rem;
}

form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

label {
  font-weight: 600;
}

input[type="text"],
input[type="file"] {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 0.5rem;
}

button {
  margin-top: 0.5rem;
  padding: 0.9rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: white;
  background: #c98a8a;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
}

button:disabled {
  opacity: 0.6;
}

#status {
  text-align: center;
  min-height: 1.5rem;
  font-weight: 600;
}

#upload-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

@media (max-width: 400px) {
  body {
    padding: 1rem;
  }

  #upload-list {
    gap: 0.5rem;
  }

  .upload-row {
    padding: 0.4rem;
  }
}

.upload-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: white;
  border: 1px solid #eee;
  border-radius: 0.6rem;
  padding: 0.6rem;
  min-width: 0;
}

.upload-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 0.5rem;
  background: #f0e8e4;
  overflow: hidden;
}

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

.upload-thumb-media {
  cursor: pointer;
}

.upload-remove {
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  width: 1.5rem;
  height: 1.5rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  color: #c0392b;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.upload-remove svg {
  width: 0.85rem;
  height: 0.85rem;
  fill: currentColor;
  display: block;
}

.upload-remove[hidden] {
  display: none;
}

.upload-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.upload-name {
  font-size: 0.75rem;
  color: #666;
  overflow-wrap: anywhere;
}

.upload-final-name {
  font-size: 0.75rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.upload-info progress {
  width: 100%;
  height: 0.5rem;
  accent-color: #c98a8a;
}

.upload-state {
  font-size: 0.8rem;
  font-weight: 600;
  color: #777;
}

.upload-state--done {
  color: #3a8a3a;
}

.upload-state--error {
  color: #c0392b;
}

.upload-type-icon {
  position: absolute;
  bottom: 0.3rem;
  right: 0.3rem;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.upload-type-icon svg {
  width: 0.85rem;
  height: 0.85rem;
  fill: currentColor;
  display: block;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 1000;
}

.lightbox[hidden] {
  display: none;
}

.lightbox-content img,
.lightbox-content video {
  display: block;
  max-width: 100%;
  max-height: 90vh;
  border-radius: 0.5rem;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2.2rem;
  height: 2.2rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  color: #333;
  font-size: 1.3rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
