/* Image uploader */
.iu-overlay { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; background: rgba(20, 16, 36, .62); backdrop-filter: blur(3px); padding: 16px; }
.iu-overlay-light { background: rgba(255, 255, 255, .55); }
.iu-fade-in { animation: iu-fade-in .2s ease-out both; }
.iu-fade-out { animation: iu-fade-out .18s ease-in both; }
@keyframes iu-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes iu-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes iu-pop { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }

.iu-dialog { background: #fff; border-radius: 14px; box-shadow: 0 24px 60px rgba(0, 0, 0, .35); width: 100%; max-width: 520px; max-height: 100%; overflow: auto; outline: none; animation: iu-pop .25s ease-out both; }
.iu-dialog-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid #eee; }
.iu-dialog-title { margin: 0; font-size: 1.05rem; font-weight: 600; color: #333; }
.iu-dialog-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid #eee; }

.iu-stage-wrap { display: flex; justify-content: center; padding: 18px 18px 6px; background: #f6f4fa; }
.iu-stage { position: relative; background: #111; border-radius: 8px; overflow: hidden; cursor: grab; touch-action: none; user-select: none; box-shadow: 0 4px 16px rgba(0, 0, 0, .25); }
.iu-stage.iu-grabbing { cursor: grabbing; }
.iu-stage-round { border-radius: 50%; }
.iu-canvas { display: block; }
.iu-grid { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .2s; background-image: linear-gradient(rgba(255,255,255,.35) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.35) 1px, transparent 1px); background-size: 33.333% 33.333%; }
.iu-stage:hover .iu-grid, .iu-stage.iu-grabbing .iu-grid { opacity: 1; }
.iu-stage-round .iu-grid { display: none; }
.iu-hint { text-align: center; font-size: .78rem; color: #777; padding: 8px 18px 0; }
.iu-controls { display: flex; align-items: center; gap: 8px; padding: 10px 18px 14px; flex-wrap: wrap; justify-content: center; }
.iu-slider { flex: 1 1 140px; min-width: 120px; accent-color: #634099; }

.iu-btn { border: 0; border-radius: 8px; padding: 8px 16px; font-size: .9rem; font-weight: 600; cursor: pointer; transition: transform .1s, box-shadow .2s, background .2s; }
.iu-btn:active { transform: scale(.97); }
.iu-btn:disabled { opacity: .7; cursor: default; }
.iu-btn-primary { background: #634099; color: #fff; }
.iu-btn-primary:hover:not(:disabled) { background: #54348a; box-shadow: 0 4px 12px rgba(99, 64, 153, .4); }
.iu-btn-secondary { background: #ececf1; color: #333; }
.iu-btn-secondary:hover { background: #dfdfe6; }
.iu-btn-ghost { background: transparent; color: #634099; padding: 6px 10px; }
.iu-btn-ghost:hover { background: #f0eaf8; }
.iu-btn.iu-busy { position: relative; }
.iu-icon-btn { width: 34px; height: 34px; border-radius: 50%; border: 0; background: #f0eaf8; color: #634099; font-size: 1.2rem; line-height: 1; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.iu-icon-btn:hover { background: #e2d6f2; }
.iu-btn:focus-visible, .iu-icon-btn:focus-visible, .iu-stage:focus-visible { outline: 3px solid rgba(99, 64, 153, .45); outline-offset: 2px; }

.iu-spinner { width: 48px; height: 48px; border-radius: 50%; border: 4px solid rgba(99, 64, 153, .2); border-top-color: #634099; animation: iu-spin .8s linear infinite; }
@keyframes iu-spin { to { transform: rotate(360deg); } }

/* Upload overlay */
.iu-upload-box { background: #fff; border-radius: 16px; padding: 28px 36px; text-align: center; min-width: 280px; max-width: 340px; box-shadow: 0 24px 60px rgba(0, 0, 0, .35); animation: iu-pop .25s ease-out both; }
.iu-ring { position: relative; width: 96px; height: 96px; margin: 0 auto 14px; }
.iu-ring svg { transform: rotate(-90deg); }
.iu-ring-bg { fill: none; stroke: #ece7f5; stroke-width: 7; }
.iu-ring-fg { fill: none; stroke: #634099; stroke-width: 7; stroke-linecap: round; transition: stroke-dashoffset .2s ease-out, stroke .3s; }
.iu-ring-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #634099; font-size: 1.1rem; }
.iu-processing .iu-ring-fg { animation: iu-pulse 1s ease-in-out infinite; }
@keyframes iu-pulse { 50% { opacity: .45; } }
.iu-upload-title { font-weight: 700; color: #2b2b2b; }
.iu-upload-sub { font-size: .85rem; color: #777; margin-top: 2px; }
.iu-shimmer { height: 6px; border-radius: 3px; margin-top: 16px; background: linear-gradient(90deg, #ece7f5 25%, #d4c6ea 50%, #ece7f5 75%); background-size: 200% 100%; animation: iu-shimmer 1.2s linear infinite; }
@keyframes iu-shimmer { to { background-position: -200% 0; } }
.iu-success .iu-ring-fg { stroke: #28a745; }
.iu-success .iu-ring-text { color: #28a745; font-size: 2rem; }
.iu-success .iu-shimmer, .iu-failed .iu-shimmer { display: none; }
.iu-failed .iu-ring-fg { stroke: #dc3545; }
.iu-failed .iu-ring-text { color: #dc3545; font-size: 2rem; }
.iu-upload-actions { display: flex; gap: 8px; justify-content: center; margin-top: 16px; }

/* Dropzone + preview */
.iu-dropzone { transition: background .2s, outline-color .2s; border-radius: 8px; }
.iu-dragover { background: #f0eaf8; outline: 2px dashed #634099; outline-offset: 4px; }
.iu-preview-in { animation: iu-pop .3s ease-out both; }
.iu-card { display: flex; align-items: center; gap: 12px; margin-top: 10px; padding: 8px 10px; border: 1px solid #e5e0ee; border-radius: 10px; background: #faf8fd; }
.iu-card-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
.iu-card-meta { flex: 1; min-width: 0; }
.iu-card-name { font-size: .88rem; font-weight: 600; color: #333; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iu-card-size { font-size: .75rem; color: #888; }

.iu-toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; z-index: 2100; background: #3b2a5c; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: .9rem; box-shadow: 0 8px 24px rgba(0, 0, 0, .3); transition: opacity .25s, transform .25s; max-width: calc(100% - 32px); }
.iu-toast-show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
    .iu-fade-in, .iu-fade-out, .iu-dialog, .iu-upload-box, .iu-preview-in, .iu-spinner, .iu-shimmer, .iu-processing .iu-ring-fg { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
