* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-gradient: #111111;
    --secondary-gradient: #666666;
    --success-gradient: #199;
    --bg-dark: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f7f7f7;
    --text-primary: #111111;
    --text-secondary: rgba(0, 0, 0, 0.7);
    --border-color: rgba(0, 0, 0, 0.08);
    --shadow-glow: none; 
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background: var(--bg-dark);
    background-image: none;
    min-height: 100vh;
    color: var(--text-primary);
} 

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 40px;
}

.title {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
} 

.title-icon {
    font-size: 2.2rem;
    -webkit-text-fill-color: initial;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Section Titles */
.section-title {
    font-size: 1.2rem;
    font-weight: 500;
    margin-bottom: 20px;
    padding-left: 15px;
    border-left: 4px solid;
    border-image: var(--primary-gradient) 1;
}

.section-desc {
    color: var(--text-secondary);
    margin-bottom: 15px;
    font-size: 0.95rem;
}

/* URL Section */
.url-section {
    background: var(--bg-card);
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    backdrop-filter: none;
    box-shadow: none;
} 

.url-textarea {
    width: 100%;
    min-height: 150px;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: #ffffff;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: 'Consolas', 'Monaco', monospace;
    line-height: 1.6;
    resize: vertical;
    transition: none;
    margin-bottom: 12px;
} 

.url-textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.3);
}

.url-textarea::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.load-url-btn {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: none;
    font-family: inherit;
    margin-bottom: 16px;
} 

.load-url-btn:hover {
    transform: none;
    box-shadow: none;
    background: var(--bg-card-hover);
} 

.url-hint {
    background: rgba(102, 126, 234, 0.1);
    border-radius: 12px;
    padding: 18px;
    border-left: 4px solid #667eea;
}

.url-hint p {
    color: var(--text-primary);
    margin-bottom: 10px;
}

.url-hint ol {
    color: var(--text-secondary);
    padding-left: 20px;
    font-size: 0.9rem;
    line-height: 1.8;
}

/* Layout Section */
.layout-section {
    background: var(--bg-card);
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    backdrop-filter: none;
    box-shadow: none;
    animation: none;
} 

.layout-options {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.layout-option {
    cursor: pointer;
    text-align: center;
}

.layout-option input {
    display: none;
}

.layout-preview {
    width: 100px;
    height: 100px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 8px;
    display: grid;
    gap: 4px;
    transition: all 0.3s ease;
    background: rgba(0, 0, 0, 0.2);
}

.layout-option:hover .layout-preview {
    border-color: rgba(102, 126, 234, 0.5);
}

.layout-option input:checked+.layout-preview {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.2);
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.3);
}

.grid-layout-preview {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

.vertical-layout-preview {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(4, 1fr);
}

.horizontal-layout-preview {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: 1fr;
    align-items: center;
}

.mini-box {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.7);
}

.layout-label {
    display: block;
    margin-top: 10px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.layout-option input:checked~.layout-label {
    color: #667eea;
    font-weight: 500;
}

/* Preview Section */
.preview-section {
    background: var(--bg-card);
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    backdrop-filter: none;
    box-shadow: none;
    animation: none;
} 

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.image-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    cursor: grab;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.image-item:hover {
    transform: none;
    box-shadow: none;
} 

.image-item.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.image-item.drag-over {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.2);
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #f5f5f5;
    display: block;
} 

.image-item .order-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 28px;
    height: 28px;
    background: var(--bg-card);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    box-shadow: none;
    color: var(--text-primary);
} 

.image-item .drag-hint {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%) translateY(6px);
    background: rgba(255, 255, 255, 0.95);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
    opacity: 0;
    transition: opacity 0.18s ease, transform 0.18s ease;
    pointer-events: none;
    box-shadow: 0 1px 0 rgba(0,0,0,0.03);
}

.image-item:hover .drag-hint,
.image-item:focus-within .drag-hint {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Per-image loading state (used if added by JS) */
.image-item.loading {
    position: relative;
}

.image-item.loading::after {
    content: '読み込み中...';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.85);
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.95rem;
    border-radius: inherit;
}


/* Action Section */
.action-section {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 30px;
    animation: fadeIn 0.3s ease;
}

.combine-btn,
.reset-btn,
.download-btn {
    padding: 14px 30px;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    font-family: inherit;
}

.combine-btn {
    background: #111111;
    color: #ffffff;
    box-shadow: none;
} 

.combine-btn:hover {
    transform: none;
    box-shadow: none;
    opacity: 0.95;
} 

.reset-btn {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.reset-btn:hover {
    background: var(--bg-card-hover);
    transform: none;
} 

.btn-icon {
    font-size: 1.2rem;
}

/* Result Section */
.result-section {
    display: none;
    background: var(--bg-card);
    border-radius: 6px;
    padding: 16px;
    border: 1px solid var(--border-color);
    backdrop-filter: none;
    animation: none;
    box-shadow: none;
} 

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-section.visible {
    display: block;
}

.result-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    overflow: auto;
}

#resultCanvas {
    max-width: 100%;
    max-height: 500px;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.download-section {
    display: flex;
    justify-content: center;
}

.download-btn {
    background: var(--success-gradient);
    color: white;
    box-shadow: 0 10px 30px rgba(17, 153, 142, 0.4);
}

.download-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(17, 153, 142, 0.5);
}

/* Loading Overlay */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 12px;
    color: var(--text-primary);
}

.loading-overlay.visible {
    display: flex;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(0, 0, 0, 0.08);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-overlay p {
    margin: 0;
    color: var(--text-primary);
    font-weight: 500;
}


/* Error Message */
.error-message {
    display: none;
    background: rgba(255, 71, 87, 0.2);
    border: 1px solid rgba(255, 71, 87, 0.5);
    border-radius: 12px;
    padding: 15px 20px;
    margin-bottom: 20px;
    color: #ff4757;
    text-align: center;
}

.error-message.visible {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* Footer */
.footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 25px;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 700px) {
    .title {
        font-size: 1.6rem;
    }

    .title-icon {
        font-size: 1.6rem;
    }

    .url-section,
    .layout-section,
    .preview-section {
        padding: 18px;
    }

    .action-section {
        flex-direction: column;
        gap: 12px;
    }

    .combine-btn,
    .reset-btn,
    .download-btn {
        width: 100%;
        justify-content: center;
    }

    .layout-preview {
        width: 80px;
        height: 80px;
    }

    .image-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}