* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

@font-face {
    font-family: 'Formula1';
    src: url('Formula1-Bold.ttf') format('truetype');
    font-weight: bold;
    font-style: normal;
}

body {
    font-family: 'Formula1', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    color: #fff;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

header {
    text-align: center;
    margin-bottom: 40px;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(90deg, #e94560, #ff6b6b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.subtitle {
    color: #8892b0;
    font-size: 1.1rem;
}

/* Upload Area */
.upload-area {
    border: 3px dashed #4a5568;
    border-radius: 20px;
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.02);
}

.upload-area:hover {
    border-color: #e94560;
    background: rgba(233, 69, 96, 0.05);
}

.upload-area.drag-over {
    border-color: #e94560;
    background: rgba(233, 69, 96, 0.1);
    transform: scale(1.02);
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.upload-area p {
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: #ccd6f6;
}

.upload-hint {
    color: #8892b0 !important;
    font-size: 0.9rem !important;
}

/* Editor Container */
.editor-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-top: 40px;
}

@media (max-width: 900px) {
    .editor-container {
        grid-template-columns: 1fr;
    }
}

.preview-section, .result-section {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.preview-section h3, .result-section h3 {
    font-size: 1rem;
    color: #8892b0;
    margin-bottom: 16px;
    font-weight: 500;
}

/* Crop Container */
.crop-container {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 8px;
    background: #000;
}

.crop-container img {
    width: 100%;
    display: block;
}

.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.crop-area {
    position: absolute;
    left: 0;
    right: 0;
    height: 0;
    border: 3px solid #e94560;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}

.crop-area::before,
.crop-area::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    border-top: 1px dashed rgba(255, 255, 255, 0.3);
}

.crop-area::before {
    top: 33.33%;
}

.crop-area::after {
    top: 66.66%;
}

/* Controls */
.controls {
    margin-top: 20px;
}

.ratio-selector {
    margin-bottom: 20px;
}

.ratio-label {
    display: block;
    color: #8892b0;
    font-size: 0.85rem;
    margin-bottom: 12px;
}

.ratio-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ratio-btn {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #8892b0;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ratio-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ccd6f6;
}

.ratio-btn.active {
    background: rgba(233, 69, 96, 0.2);
    border-color: #e94560;
    color: #e94560;
}

.controls label {
    display: flex;
    align-items: center;
    gap: 15px;
    color: #ccd6f6;
}

.position-control {
    display: flex;
    align-items: center;
    gap: 15px;
    color: #ccd6f6;
}

.controls input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    background: #4a5568;
    border-radius: 3px;
    cursor: pointer;
}

.controls input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: #e94560;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
}

.controls input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

#positionValue {
    min-width: 50px;
    text-align: right;
    color: #e94560;
    font-weight: 600;
}

/* Result Container */
.result-container {
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
}

#resultCanvas {
    width: 100%;
    display: block;
}

/* Info Bar */
.info-bar {
    display: flex;
    justify-content: space-between;
    margin-top: 16px;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    font-size: 0.85rem;
    color: #8892b0;
}

/* Buttons */
.action-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.btn {
    flex: 1;
    padding: 14px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #e94560, #ff6b6b);
    color: #fff;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(233, 69, 96, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #ccd6f6;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-danger {
    background: rgba(233, 69, 96, 0.1);
    color: #e94560;
    border: 1px solid rgba(233, 69, 96, 0.3);
}

.btn-danger:hover {
    background: rgba(233, 69, 96, 0.2);
}

/* Footer */
footer {
    text-align: center;
    margin-top: 60px;
    padding-top: 30px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: #8892b0;
    font-size: 0.9rem;
}

/* Mode Switcher */
.mode-switcher {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
}

.mode-btn {
    padding: 10px 24px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #8892b0;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ccd6f6;
}

.mode-btn.active {
    background: rgba(233, 69, 96, 0.2);
    border-color: #e94560;
    color: #e94560;
}

/* Stitch Upload Area */
.stitch-upload-area {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    padding: 32px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.stitch-upload-area h3 {
    color: #8892b0;
    font-size: 1rem;
    margin-bottom: 24px;
    font-weight: 500;
}

.stitch-images {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.stitch-slot {
    width: 200px;
    height: 150px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px dashed rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stitch-slot:hover {
    border-color: #e94560;
    background: rgba(233, 69, 96, 0.05);
}

.stitch-slot-content {
    text-align: center;
    color: #8892b0;
}

.slot-number {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    color: #e94560;
    margin-bottom: 8px;
}

.stitch-slot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-stitch-img {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(233, 69, 96, 0.9);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.stitch-plus {
    font-size: 2rem;
    color: #e94560;
    font-weight: bold;
}

/* Progress Bar */
.progress-container {
    margin: 20px auto;
    max-width: 500px;
}

.progress-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #e94560, #ff6b6b);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-text {
    color: #8892b0;
    font-size: 0.85rem;
    margin-top: 8px;
    text-align: center;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.editor-container, .batch-container, .stitch-upload-area {
    animation: fadeIn 0.5s ease;
}

/* ===== BATCH CONTAINER ===== */
.batch-container {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 40px;
}

.batch-container h3 {
    font-size: 1rem;
    color: #8892b0;
    margin-bottom: 20px;
    font-weight: 500;
}

.batch-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    margin-bottom: 20px;
}

.batch-ratio label,
.batch-position label {
    display: block;
    color: #8892b0;
    font-size: 0.85rem;
    margin-bottom: 12px;
}

.batch-position {
    display: flex;
    align-items: center;
    gap: 16px;
}

.batch-position label {
    margin-bottom: 0;
}

.batch-position input[type="range"] {
    width: 200px;
    height: 6px;
    -webkit-appearance: none;
    background: #4a5568;
    border-radius: 3px;
    cursor: pointer;
}

.batch-position input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: #e94560;
    border-radius: 50%;
    cursor: pointer;
}

.batch-position span {
    color: #e94560;
    font-weight: 600;
    min-width: 40px;
}

/* Image Queue */
.image-queue {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 8px;
}

.image-queue::-webkit-scrollbar {
    width: 6px;
}

.image-queue::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.image-queue::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.queue-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    transition: all 0.3s ease;
}

.queue-item:hover {
    background: rgba(0, 0, 0, 0.3);
}

.queue-thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: #000;
}

.queue-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.queue-info {
    flex: 1;
    min-width: 0;
}

.queue-name {
    display: block;
    color: #ccd6f6;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.queue-size {
    display: block;
    color: #8892b0;
    font-size: 0.8rem;
}

.queue-preview {
    width: 80px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
}

.queue-preview canvas {
    width: 100%;
    display: block;
}

.queue-remove {
    width: 36px;
    height: 36px;
    background: rgba(233, 69, 96, 0.1);
    border: 1px solid rgba(233, 69, 96, 0.3);
    border-radius: 8px;
    color: #e94560;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.queue-remove:hover {
    background: rgba(233, 69, 96, 0.2);
}

/* Batch Actions */
.batch-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

/* ===== WATERMARK SECTION ===== */
.watermark-section {
    margin-top: 16px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.watermark-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    color: #ccd6f6;
    font-size: 0.9rem;
}

.watermark-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #e94560;
    cursor: pointer;
}

.toggle-label {
    user-select: none;
}

.watermark-settings {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.watermark-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.watermark-row:last-child {
    margin-bottom: 0;
}

.watermark-row label {
    min-width: 50px;
    color: #8892b0;
    font-size: 0.85rem;
}

.watermark-row select,
.watermark-row input[type="text"] {
    flex: 1;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #ccd6f6;
    font-family: inherit;
    font-size: 0.85rem;
}

.watermark-row select:focus,
.watermark-row input[type="text"]:focus {
    outline: none;
    border-color: #e94560;
}

.watermark-row select option {
    background: #1a1a2e;
    color: #ccd6f6;
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
    .container {
        padding: 20px 16px;
    }

    header h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .upload-area {
        padding: 40px 20px;
    }

    .upload-icon {
        font-size: 3rem;
    }

    .editor-container {
        gap: 20px;
    }

    .batch-controls {
        flex-direction: column;
        gap: 16px;
    }

    .batch-position {
        flex-wrap: wrap;
    }

    .batch-position input[type="range"] {
        width: 100%;
        order: 1;
    }

    .queue-item {
        flex-wrap: wrap;
    }

    .queue-preview {
        display: none;
    }

    .action-buttons, .batch-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .info-bar {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
    }

    .ratio-btn {
        padding: 6px 12px;
        font-size: 0.75rem;
    }

    .btn {
        padding: 12px 20px;
        font-size: 0.9rem;
    }
}