:root {
  --ink: #515151;
  --heading: #303030;
  --accent: #4141a5;
  --accent-dark: #081e77;
  --line: #e5e5e5;
  --ok: #1f8a4c;
  --err: #c0392b;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { font-family: "PT Sans", Helvetica, Arial, sans-serif; }
@media (min-width: 48em) { html { font-size: 16px; } }
@media (min-width: 58em) { html { font-size: 20px; } }
body { color: var(--ink); background: #fff; -webkit-text-size-adjust: 100%; }

.container { margin: 3rem auto 4rem; padding: 0 20px; max-width: 720px; }
h1 { font-size: 2rem; text-align: center; color: var(--heading); margin: 0 0 1rem; line-height: 1.25; }
.form-group { margin-bottom: 1rem; }
label { display: block; margin-bottom: .5rem; }
.optional-label { color: #888; font-size: .9em; font-weight: normal; }

input[type=text], input[type=email], select, textarea {
  width: 100%; padding: 10px; border: 2px solid var(--line); border-radius: 6px;
  font: inherit; font-size: 1rem; background: #fff; transition: border-color .2s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
.invalid { border-color: var(--err) !important; }
textarea { resize: vertical; min-height: 80px; }

/* Dropzone */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: .25rem;
  padding: 1.5rem 1rem; margin: 0; text-align: center; cursor: pointer;
  border: 2px dashed var(--line); border-radius: 10px;
  transition: border-color .2s, background .2s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: #f6f6fd; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dropzone:focus-within { border-color: var(--accent); }
.dropzone-title { color: var(--accent); font-weight: 700; }
.dropzone-sub { font-size: .8em; color: #888; }
.dropzone.locked { pointer-events: none; opacity: .5; }

/* Photo tray */
.tray {
  display: grid; gap: 14px; margin-top: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
}
.photo {
  position: relative; aspect-ratio: 3 / 4; background: #fff; padding: 6px 6px 6px;
  border-radius: 4px; box-shadow: 0 2px 10px rgba(0,0,0,.18);
  transform: rotate(var(--tilt, 0deg)); transition: transform .2s, box-shadow .2s;
  animation: pop .3s ease-out both;
}
.photo:hover { transform: rotate(0) scale(1.03); box-shadow: 0 6px 18px rgba(0,0,0,.25); z-index: 1; }
@keyframes pop { from { opacity: 0; transform: scale(.85) rotate(var(--tilt, 0deg)); } }
.photo .thumb {
  position: relative; width: 100%; height: 100%; border-radius: 2px; overflow: hidden;
  background: #ececf3 linear-gradient(110deg, #ececf3 30%, #f7f7fb 50%, #ececf3 70%) 0 0 / 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
.photo .thumb.ready, .photo .thumb.nopreview { animation: none; }
@keyframes shimmer { to { background-position: -200% 0; } }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .ext { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; color: #8a8ab0; font-size: 1.1rem; }

.remove {
  position: absolute; top: -8px; right: -8px; width: 26px; height: 26px; border-radius: 50%;
  border: none; background: var(--heading); color: #fff; font-size: 16px; line-height: 1; cursor: pointer;
  opacity: 0; transition: opacity .15s; display: grid; place-items: center; padding: 0;
}
.photo:hover .remove, .remove:focus-visible { opacity: 1; }
@media (hover: none) { .remove { opacity: 1; } }

/* Per-photo progress */
.overlay {
  position: absolute; inset: 6px; border-radius: 2px; display: grid; place-items: center;
  background: rgba(8, 30, 119, .0); transition: background .25s; pointer-events: none;
}
.photo.uploading .overlay, .photo.queued .overlay { background: rgba(8, 30, 119, .45); }
.photo.done .overlay { background: rgba(31, 138, 76, .55); }
.photo.error .overlay { background: rgba(192, 57, 43, .6); pointer-events: auto; }
.ring { width: 54px; height: 54px; transform: rotate(-90deg); display: none; }
.photo.uploading .ring { display: block; }
.ring circle { fill: none; stroke-width: 5; }
.ring .track { stroke: rgba(255,255,255,.3); }
.ring .bar { stroke: #fff; stroke-linecap: round; stroke-dasharray: 138.2; stroke-dashoffset: 138.2; transition: stroke-dashoffset .15s linear; }
.pct { position: absolute; color: #fff; font-weight: 700; font-size: .7rem; display: none; }
.photo.uploading .pct { display: block; }
.state-icon { color: #fff; font-size: 1.8rem; font-weight: 700; display: none; }
.photo.done .state-icon.check, .photo.error .state-icon.retry { display: block; }
.photo.queued .queued-label { display: block; }
.queued-label { display: none; color: #fff; font-size: .7rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.photo.done .check { animation: checkpop .35s ease-out; }
@keyframes checkpop { from { transform: scale(.3); opacity: 0; } 60% { transform: scale(1.2); } }
.retry-btn { pointer-events: auto; background: none; border: none; color: #fff; cursor: pointer; font: inherit; font-size: .75rem; font-weight: 700; text-align: center; }
.retry-btn span { display: block; font-size: 1.6rem; }

.summary { margin-top: .75rem; font-size: .85rem; color: #777; }
.summary strong { color: var(--ink); }

/* Submit button + overall progress */
.upload-btn {
  width: 100%; padding: 1rem 2rem; color: #fff; border: none; border-radius: 6px;
  background-image: linear-gradient(315deg, #081e77, #4141a5);
  font: inherit; font-size: 1rem; font-weight: 700; cursor: pointer; transition: opacity .2s;
}
.upload-btn:hover:not(:disabled) { opacity: .9; }
.upload-btn:disabled { opacity: .6; cursor: not-allowed; }

.overall { margin-top: 1rem; }
.overall-bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.overall-fill { height: 100%; width: 0; background-image: linear-gradient(90deg, #4141a5, #081e77); border-radius: 999px; transition: width .2s linear; }
.overall p { margin: .5rem 0 0; text-align: center; font-size: .85rem; color: var(--accent); font-weight: 700; }

/* Toasts */
.toasts {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 100;
  width: min(92vw, 520px); display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: .75rem;
  padding: .85rem 1rem; border-radius: 10px; color: #fff; font-size: .85rem; font-weight: 700;
  box-shadow: 0 8px 28px rgba(0,0,0,.28); animation: toast-in .3s cubic-bezier(.2,.9,.3,1.2) both;
}
.toast.error { background: var(--err); }
.toast.success { background: var(--ok); }
.toast.leaving { animation: toast-out .25s ease-in forwards; }
.toast-icon {
  flex: none; width: 24px; height: 24px; border-radius: 50%; background: rgba(255,255,255,.25);
  display: grid; place-items: center; font-size: .9rem;
}
.toast-text { flex: 1; line-height: 1.3; }
.toast-close {
  flex: none; background: none; border: none; color: #fff; font-size: 1.4rem; line-height: 1;
  cursor: pointer; opacity: .8; padding: 0 .25rem;
}
.toast-close:hover { opacity: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-16px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-12px); } }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .photo, .photo .thumb, .check, .toast { animation: none !important; }
}
